Pivy problem and some other stuff
Scott David Daniels
daniels at dsl-only.net
Thu Aug 30 23:10:47 EDT 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