Pivy problem and some other stuff

Scott David Daniels daniels at dsl-only.net
Fri Aug 31 05:10:47 CEST 2007


Marc 'BlackJack' Rintsch wrote:
A fine repy
> In [57]: funcs = [a, b]
> In [58]: funcs
> Out[58]: [<function a at 0xb7792e2c>, <function b at 0xb779e1ec>]
> 
> In [59]: funcs[0]()
> Out[59]: 1
> 
> In [60]: funcs[1]()
> Out[60]: 2

and a "list comprehension" allows you to call these things no matter how
long the list is.

So after the above:
     >>> results = [f() for f in funcs]
     >>> print results
     [1, 2]



More information about the Python-list mailing list