Created
January 26, 2015 00:07
-
-
Save sujayy1983/03cd0952067a348319c8 to your computer and use it in GitHub Desktop.
Fun with *args and **kwargs
This file contains 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
""" | |
@Author: Sujayyendhiren Ramarao Srinivasamurthi | |
@Description: Fun with args and kwargs | |
""" | |
def function1 ( *args, ** kwargs): | |
print "" | |
print args | |
print kwargs | |
print "" | |
""" Naming doesnt matter but order of * and ** does matter""" | |
def function2 ( *xyz, **abcd): | |
print "" | |
print xyz | |
print abcd | |
print "" | |
function1 ( 1 , 2 ,3 ) | |
function1 (one=1, two=2, three=3) | |
function1 (1, 2, 3 , one=1, two=2, three=3) | |
#function1 (1, 2, one=1, 3, two=2, three=3) Invalid: Keyed values must be in the end | |
function2 ( 1 , 2 ,3 ) | |
function2 (one=1, two=2, three=3) | |
function2 (1, 2, 3 , one=1, two=2, three=3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment