On Mar 22, 8:51 am, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
> If you drop this condition then you could fill the array with zeroes
> as before, replace only the interesting ones with actual functions,
> and write:
>
> for item in myarray[nonzero(myarray)]:
> print item() if callable(item) else item
>
Let's unbuckle the seat belt :-)
If "item" is definitely restricted to being either 0 or a callable
object, then
item() if item else 0
should give the same answer as, and is quite likely to be faster than,
item() if callable(item) else item
as it avoids a global lookup and a function call.
Cheers,
John
--
http://mail.python.org/mailman/listinfo/python-list