Created
May 25, 2013 08:47
-
-
Save Abhishek-Srivastava/5648400 to your computer and use it in GitHub Desktop.
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
def var_args(farg1, farg2, *args, **kargs): | |
print "formal arg:", farg1 | |
print "formal arg:", farg2 | |
print 'Length of', len(args) | |
for arg in args: | |
print 'vararg:' , arg | |
for key in kargs: | |
print key | |
sample_keyarg = {1:’abhi’, 2:’smart’} | |
var_args(1,2, sample_keyarg, “abhi”, “kk”, “jj”, (“r”, “p”), ram = 85, shyam=45 ) | |
#Output: | |
#formal arg: 1 | |
#formal arg: 2 | |
#Length of args 5 | |
#vararg: {1: 'abhi', 2: 'smart'} | |
#vararg: abhi | |
#vararg: kk | |
#vararg: jj | |
#vararg: ('r', 'p') | |
#ram | |
#shyam |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment