Skip to content

Instantly share code, notes, and snippets.

@sujayy1983
Created January 26, 2015 00:07
Show Gist options
  • Save sujayy1983/03cd0952067a348319c8 to your computer and use it in GitHub Desktop.
Save sujayy1983/03cd0952067a348319c8 to your computer and use it in GitHub Desktop.
Fun with *args and **kwargs
"""
@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