[Python-Dev] The iterator story
Oren Tirosh
oren-py-d@hishome.net
Sun, 21 Jul 2002 08:40:14 +0300
On Sat, Jul 20, 2002 at 10:13:34AM -0400, Guido van Rossum wrote:
> > It seems like a strange design decision to put the burden on all iterator
> > implementers to write a dummy method returning self instead of just checking
> > if tp_iter==NULL in PyObject_GetIter. It's like requiring all class writers
> > to write a dummy __str__ method that calls __repr__ instead of implementing
> > the automatic fallback to __repr__ in PyObject_Str when no __str__ is
> > available.
>
> I suppose you meant "check for tp_iter==NULL and tp_iternext!=NULL.
Yes.
Any comments on my analogy of __iter__/next with __str__/__repr__ and the
burden of implementation?
Oren