Variable Length ArgumentsA function accepting variable number of arguments
def printf(fmt, *args):
print fmt % args
Accepting an arbitrary set of keyword arguments
def foo(**kwargs):
print kwargs
Accepting both positional and keyword arguments
def 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 |
>>> |