Created
May 31, 2020 14:57
-
-
Save eclecticmiraclecat/64435c8e1f592e94525d36efa355c9ae to your computer and use it in GitHub Desktop.
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 func(x, y, z): | |
... print(x, y, z) | |
... | |
>>> func(1, 2, 3) | |
1 2 3 | |
>>> func(1, z=3, y=2) | |
1 2 3 | |
>>> def func(x, *args): | |
... print(x) | |
... print(args) | |
... | |
>>> func(1) | |
1 | |
() | |
>>> func(1, 2, 3, 4, 5) | |
1 | |
(2, 3, 4, 5) | |
>>> def func(x, **kwargs): | |
... print(x) | |
... print(kwargs) | |
... | |
>>> func(1, xmin=10, xmax=20, color='red') | |
1 | |
{'xmin': 10, 'xmax': 20, 'color': 'red'} | |
>>> def func(*args, **kwargs): | |
... print(args) | |
... print(kwargs) | |
... | |
>>> func() | |
() | |
{} | |
>>> func(1,2,3,4) | |
(1, 2, 3, 4) | |
{} | |
>>> func(1, 2, x=4, y=3) | |
(1, 2) | |
{'x': 4, 'y': 3} | |
>>> | |
>>> | |
>>> def func(a, b, c, d): | |
... print(a, b, c, d) | |
... | |
>>> args = (1, 2) | |
>>> kwargs = {'c':3, 'd':4} | |
>>> func(*args, **kwargs) | |
1 2 3 4 | |
>>> data = (1, 2, 3, 4) | |
>>> func(*data) | |
1 2 3 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment