Created
          December 13, 2013 19:35 
        
      - 
      
- 
        Save diminoten/7949923 to your computer and use it in GitHub Desktop. 
    Tuples as function args
  
        
  
    
      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
    
  
  
    
  | #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