some random reflections...

alex at magenta.com alex at magenta.com
Thu Dec 9 15:00:42 EST 1999


Steve Tregidgo (smst at quantisci.co.uk) writes:
    [snip]
> So, if you can't easily get the Nth item but can get the "next" item
> (as you mention below), you are at least okay in a for-loop -- just
> remember the last thing you sent out from __getitem__ and work out

But that would break if two loops were nested, a frequent need:
    for a in X:
        for b in X:
            mungle(a,b)
as I mentioned in passing, in explaining why I think it would be
better for X to be able to return an "enumerator object" (one
implementing __next__ kinds of things) rather than doing the
__next__-ish things itself -- that would break nested loops.


Alex




Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list