Both keyword and non-keyword variable arguments may be used in the same function as long as the keyword dictionary is last : Varible length parameter : Function PYTHON TUTORIALS


PYTHON TUTORIALS » Function » Varible length parameter »

 

Both keyword and non-keyword variable arguments may be used in the same function as long as the keyword dictionary is last


def newfoo(arg1, arg2, *nkw, **kw):
    print 'arg1 is:', arg1
    print 'arg2 is:', arg2
    for eachNKW in nkw:
        print 'additional non-keyword arg:', eachNKW
    for eachKW in kw.keys():
        print "additional keyword arg '%s': %s" (eachKW, kw[eachKW])

newfoo('wolf', 3'projects', freud=90, gamble=96)



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Function
» Varible length parameter