while (a=b()) ...

Tim Peters tim_one at email.msn.com
Sat May 15 12:43:14 EDT 1999


[Donn Cave]
> ...
> There might be some broader mileage in the construct, for example
> "for i:" might be taken to mean "for i in range(INF):", which is a
> little awkward in the current language (best I can do is  "i = 0;
> while 1: i = i + 1; ...")

You could try

    for i in xrange(sys.maxint):

instead, or do

    perpetuity = xrange(sys.maxint)
    ...
    for i in perpetuity:

Ya, ya.

A while back we hashed out a spelling for parallel iteration, as in:

    for x in xlist; y in ylist:
        print "I'm printed min(len(x), len(y)) times."

A generalization, sneaking the old "indexing" proposal back in under a
different spelling:

    for i in *; x in xlist:
        print "The value of x[%d] is %s" % (i, x)

A degeneration:

    for i in *:
        print "perpetuity"

foreverly y'rs  - tim






More information about the Python-list mailing list