Last active
October 23, 2015 01:34
-
-
Save poros/439084cd3337d2a296c8 to your computer and use it in GitHub Desktop.
Keyword-only arguments
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(arg1, arg2, arg3=10, arg4=0): | |
... | |
# problem | |
func(1, 2, 10, 0) | |
# or ? | |
func(1, 2, 0, 10) | |
# PYTHON 3 ONLY | |
def func(arg1, arg2, *, arg3=10, arg4=0): | |
... | |
func(1, 2, 10, 0) # ERROR | |
func(1, 2, arg3=10, arg4=0) | |
# also | |
def func(arg1, *args, optional_arg=None): | |
... | |
# PYTHON 2: fun(arg1, arg2, *args, **kwargs) is similar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment