Created
October 17, 2017 20:39
-
-
Save pykong/6a9b020e4df2f56f23e89f15733dbc4b to your computer and use it in GitHub Desktop.
Python 3.5+ allows passing multiple sets of keyword arguments ("kwargs") to a function within a single call, using the `"**"` syntax.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> def process_data(a, b, c, d): | |
>>> print(a, b, c, d) | |
>>> x = {'a': 1, 'b': 2} | |
>>> y = {'c': 3, 'd': 4} | |
>>> process_data(**x, **y) | |
1 2 3 4 | |
>>> process_data(**x, c=23, d=42) | |
1 2 23 42 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment