What makes an iterator an iterator?
Alex Martelli
aleax at mac.com
Wed Apr 18 10:50:46 EDT 2007
Steven D'Aprano <steve at REMOVEME.cybersource.com.au> wrote:
> I thought that an iterator was any object that follows the iterator
> protocol, that is, it has a next() method and an __iter__() method.
The special methods need to be on the type -- having attributes of those
names on the instance doesn't help (applies to all special methods in
the normal, aka newstyle, object model; legacy, aka classic, classes,
work by slightly different and not entirely self-consistent semantics).
Alex
More information about the Python-list
mailing list