PEP 234: Iterators
aahz at panix.com
Sat May 5 19:45:32 EDT 2001
In article <6qsnij672s.fsf at abnoba.intevation.de>,
Bernhard Herzog <bh at intevation.de> wrote:
>aahz at panix.com (Aahz Maruch) writes:
>> In article <nfiI6.83$Yu6.16482 at newsc.telia.net>,
>> Fredrik Lundh <fredrik at effbot.org> 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 pobox.com)
Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/
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