[Python-ideas] iterable: next() and __iter__() -- and __reset()

Mathias Panzenböck grosser.meister.morti at gmx.net
Fri Mar 5 05:01:27 CET 2010


On 03/04/2010 10:43 PM, Georg Brandl wrote:
>> >  (2) But: for any reason next() is not spelled as a "magic" method. If this
>> >  method becomes the distinctive method of iterables, then it should be called
>> >  __next__() for consistency. Side-question: Why is it called next(), as it is
>> >  a magic method for iterators already?
> Because it is supposed to be called directly.  __iter__() isn't.  (This changes
> with Python 3, where you have next() as a builtin.)

And why is it made a builtin function? What was wrong with it being a normal method?

	-panzi



More information about the Python-ideas mailing list