PEP 276 Simple Iterator for ints (fwd)

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Mon Dec 3 10:31:38 CET 2001


Mon, 3 Dec 2001 19:27:46 +1100, Delaney, Timothy <tdelaney at avaya.com> pisze:

>> I.e. it's translated to 'while' rather than to 'for i in range'.
> 
> Definitely not. The name receiving the value from the iterator

There is no requirement to implement this as using an iterator.

> In fact, it would be impossible to do what you are suggesting unless
> you were going to have some way to inform the iterator that the
> name which received its value had been rebound.

I meant translating

    for 0 <= i < 10:
        print i

into

    i = 0
    while i < 10:
        print i
        i += 1

There is no iterator here.

There is another question: should the upper bound be reevaluated each
time? Again it's a silly idea to depend on that, but it should have
some semantics.

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^
QRCZAK



More information about the Python-list mailing list