PEP 234: Iterators

Aahz Maruch aahz at
Sat May 5 19:45:32 EDT 2001

In article <6qsnij672s.fsf at>,
Bernhard Herzog  <bh at> wrote:
>aahz at (Aahz Maruch) writes:
>> In article <nfiI6.83$Yu6.16482 at>,
>> Fredrik Lundh <fredrik at> wrote:
>>>Aahz Maruch wrote:
>>>> Well, yes.  The whole point of this exercise is that xrange() will be
>>>> essentially deprecated in 2.2.  There's no more need to create any
>>>> new x*() functions.
>>>what should you use instead of xrange?
>> range() -- at least, I'm assuming that range() will return an iterator
>> in the appropriate contexts.
>But how does range know in what context it's being called? range is
>documented as returning a list and I wouldn't be surprised if there were
>code that made use of that fact (in fact there's a place in Sketch where
>that fact is used).

I haven't checked the most recent version of PEP 234 to make sure I know
what I'm talking about, but IIRC, the idea at an earlier point was that
functions like range() would return an iterator, which would then
automatically return the entire list if a sequence operation were
performed instead of an iteration operation.
                      --- Aahz  <*>  (Copyright 2001 by aahz at

Androgynous poly kinky vanilla queer het Pythonista
Hugs and backrubs -- I break Rule 6

I don't have enough time for all the cool people I know, let alone all
the cool people *they* know.  --Aahz

More information about the Python-list mailing list