[Python-ideas] Python Users Aren't Perfect

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Dec 16 06:50:39 CET 2011

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.


More information about the Python-ideas mailing list