On Fri, Jan 23, 2009 at 12:37 PM, Tobiah <t...@tobiah.org> wrote: > On Thu, 22 Jan 2009 14:13:34 -0800, Chris Rebert wrote: > >> On Thu, Jan 22, 2009 at 2:04 PM, Tobiah <t...@tobiah.org> wrote: >>> Although it's trivial to program, I wondered whether >>> there was a builtin or particularly concise way to >>> express this idea: >>> >>>> a = [(1, 2), (3, 4), (5, 6)] >>>> field[a, 2] >>> [2, 4, 6] >>> >>> where field() is some made up function. >> >> Python 2.6 (r26:66714, Nov 18 2008, 21:48:52) >> [GCC 4.0.1 (Apple Inc. build 5484)] on darwin >> Type "help", "copyright", "credits" or "license" for more information. >>>>> a= [(1, 2), (3, 4), (5, 6)] >>>>> zip(*a) >> [(1, 3, 5), (2, 4, 6)] >>>>> zip(*a)[1] >> (2, 4, 6) > > That would be what I was after. Where can I read about > this mysterious use of the '*'? It only works in the > context of the zip() function. It's hard to understand > how the interpreter handles that.
It works in all functions. Basically: f(*[1,2,3]) === f(1,2,3) I'm sure someone will also point out the docs. Cheers, Chris -- Follow the path of the Iguana... http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list