Monday, October 27, 2008

replacement apply syntax

The useful apply() function is deprecated.

The alternative is the "extended call syntax". It looks identical to the *kargs and **kwargs syntax in function definitions, but in the inverse in that you use it to pass arguments to functions rather than defining their input.

def foo(a,b):
pass

foo(*(1,2))
foo(**{'a':1, 'b', 2})

either of these will generate errors:

foo(**{'v':3})
foo(*(1,2,3,))

No comments: