while (assignment):

Andrew Dalke adalke at mindspring.com
Tue Jul 29 20:29:59 EDT 2003


Michele Simionato
> Second answer:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/202234

I just added this alternative

>>> a = [1, 2, 9, 0]
>>> n = iter(a).next
>>> while [x for x in [n()] if x]:
...  print "I have", x
...
I have 1
I have 2
I have 9
>>>

Again, don't this in real code.  Evil.  But cute.

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list