Keyword Variable Arguments (Dictionary) : Varible length parameter « Function « Python Tutorial






def dictVarArgs(arg1, arg2='defaultB', **theRest):
    print 'formal arg1:', arg1
    print 'formal arg2:', arg2
    for eachXtrArg in theRest.keys():
        print 'Xtra arg %s: %s' % \
            (eachXtrArg, str(theRest[eachXtrArg]))

dictVarArgs(1220, 740.0, c='grail')
dictVarArgs(arg2='tales', c=123, d='poe', arg1='mystery')
dictVarArgs('one', d=10, e='zoo', men=('freud', 'gaudi'))








10.5.Varible length parameter
10.5.1.Varible length parameter
10.5.2.variable length arguments
10.5.3.Keyword Variable Arguments (Dictionary)
10.5.4.Both keyword and non-keyword variable arguments may be used in the same function as long as the keyword dictionary is last
10.5.5.Calling Functions with Variable Argument Objects
10.5.6.** works for keyword arguments: it collects them into a new dictionary,
10.5.7.A dictionary containing all keyword arguments whose keyword doesn't correspond to a formal parameter
10.5.8.*args and **kwargs example