New Function Call Syntax

Functions with variable length arguments

     # Python 1.5 version
     def wrap_foo(*pargs,**kwargs):
         print "Calling foo"
         apply(foo,pargs,kwargs)

Python 2.0 provides a new syntax that replaces apply()

 # Python 2.0 version
 def wrap_foo(*pargs,**kwargs):
     print "Calling foo"
     foo(*pargs,**kwargs)

Also works in combination with other arguments

 def foo(w,x,y,z):
     ...
 a = (3,4)
 foo(1,2,*a)       # Same as foo(1,2,3,4)
  • Note: *a and **b arguments must appear last.
<<< O'Reilly OSCON 2001, New Features in Python 2, Slide 16
July 26, 2001, beazley@cs.uchicago.edu
>>>