[Python-ideas] Python Users Aren't Perfect
masklinn at masklinn.net
Fri Dec 16 09:37:11 CET 2011
On 2011-12-16, at 06:50 , Greg Ewing wrote:
> Ned Batchelder wrote:
>> Finish that foo function definition: it will *have* to have "for a in args:"
> Not necessarily. It might be something like this:
> def foo(*args):
> if len(args) == 2:
> x, y = args
> fizzle2d(x, y)
> x, y, z = args
> fizzle3d(x, y, z)
> In other words, it might be what is effectively an
> overloaded function with a number of different possible
> calling signatures. Once you've decided which signature
> is being invoked, each member of the argument tuple
> takes on a specific role.
Is that really used instead of optional arguments with a placeholder value e.g.
def foo(x, y, z=None):
if z is None:
fizzle3d(x, y, z)
More information about the Python-ideas