[Python-ideas] iterable: next() and __iter__() -- and __reset()
andrew at bemusement.org
Fri Mar 5 05:17:59 CET 2010
Mathias Panzenböck wrote:
> 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?
More information about the Python-ideas