zip() or what?

Sean Ross sross at
Thu Jul 3 16:47:04 CEST 2003

"Ray Tomes" <rtomes at> wrote in message
news:3F0401C4.1010306 at
>... I don't get the meaning of the * [snip]. Is this like the opposite of
putting [] around something or what?

That's pretty much it. I think of it as an unpacking operator (which it
isn't, but anyway...). You can use it to unpack a list or tuple of arguments
that you want to feed into a function [1]. Conversely, you can use it when
defining a function to say "this function also takes an arbitrary number of
additional arguments"[2].

You've seen an example of [1] for your own problem, here's another quick

def foo(a, b, c):
    print "%s %s %s" % (a, b, c)
argfeed = ['a', 'b', 'c']
foo(*argfeed)    # equivalent to foo('a', 'b', 'c')

And an example of [2] would be:

def foo(*args):
    for arg in args:
        print arg
foo('a', 'b', 'c', 'hello world')

The second useage is in the tutorial [ section 4.7.3 ], I'm not sure where
the first useage is.

More information about the Python-list mailing list