Skip to content

Instantly share code, notes, and snippets.

@Streemo
Created October 26, 2014 04:22
Show Gist options
  • Save Streemo/201d85d05e4a779e5de0 to your computer and use it in GitHub Desktop.
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.
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