Variable Length ArgumentsA function accepting variable number of argumentsdef printf(fmt, *args): print fmt % args Accepting an arbitrary set of keyword argumentsdef foo(**kwargs): print kwargs Accepting both positional and keyword argumentsdef foo(arg1, *vargs, **kwargs): statements foo(1,2,3,4,name="Guido") # arg1 = 1, vargs = (2,3,4), kwargs= {'name':'Guido'} |
<<< | O'Reilly OSCON 2000, Introduction to Python, Slide 81 July 17, 2000, beazley@cs.uchicago.edu |
>>> |