Skip to content

Instantly share code, notes, and snippets.

@diminoten
Created December 13, 2013 19:35
Show Gist options
  • Save diminoten/7949923 to your computer and use it in GitHub Desktop.
Save diminoten/7949923 to your computer and use it in GitHub Desktop.
Tuples as function args
#A function with an optional argument
def foo(fee, far=None, fleeb="floob"):
print fee
if far:
print far
if fleeb:
print fleeb
#A function that accepts a tuple as its argument, and then calls another function using the accepted tuple as arguments for the called function
def bar(foo_args):
foo(*foo_args)
#Obviously tuples can't look like this - how do I set fleeb in the above function?
#bar(("Hi", fleeb="ho"))
#Will I have to do this?
bar(("Hi", None, "Fleeber"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment