Created
October 26, 2014 04:22
-
-
Save Streemo/201d85d05e4a779e5de0 to your computer and use it in GitHub Desktop.
Args and Kwargs: What you get to use in the function code block.
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 takesArbitraryNumberOfArgs(*args): | |
return args | |
#args tuple provided in function scope | |
def defineArbitraryArgsOnTheFly(**kwargs): | |
return kwargs | |
#kwargs dictionary provided in function scope. | |
x = takesArbitraryNumberOfArgs('bob,234,'lol') | |
type(x) #=>tuple | |
y = defineArbitraryArgsOnTheFly(newVar=5343,bob="bob") | |
type(y) #=> dictionary |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment