Alternative to standard C "for"
Georg Brandl
g.brandl-2005-01 at gmx.net
Sat Feb 5 14:40:45 EST 2005
Alex Martelli wrote:
> Georg Brandl <g.brandl-2005-01 at gmx.net> wrote:
>
>> Slight terminology glitch -- it does return an iterator, not a
>> generator. Generators are functions that return iterators.
>
> xrange returns an ITERABLE, not an ITERATOR. Videat:
>
>>>> a = xrange(23, 43)
>>>> a.next()
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> AttributeError: 'xrange' object has no attribute 'next'
>>>>
>
> No next method -> not an iterator. iter(xrange(...)) DOES return an
> iterator, btw.
Thanks! Somehow it's always these little corrections that contain errors.
And, considering your other posts today, I got away quite well...
Georg
More information about the Python-list
mailing list