179Re: [python-iter] Why must an iterator have an __iter__ method? (fwd)
- Mar 14, 2001[ Guido van Rossum :]
> > > We *could* add <next> sniffing, but I believe then we would have to[gzeljko:]
> > > bite the bullet and use tp_next and __next__; otherwise the sniffing
> > > is too fragile (looking for __call__ is clearly a bad idea; looking
> > > for a next() method also seems a bad idea, see above.)
> > Why 'looking for __call__ is clearly a bad idea' ?[ Guido van Rossum :]
> Because the presence of __call__ is not enough to be sure that it's anMaybe we can use some atribute only for taging iterator.
> iterator. It could be any old callable.
So if looking for (say) __iterator_tag__ succeed it is
iterator, it is callable.
This way we can use anything callable for iterator insisting
it's taged as iterator (has attribute __iterator_tag__).
- << Previous post in topic Next post in topic >>