Loading ...
Sorry, an error occurred while loading the content.

179Re: [python-iter] Why must an iterator have an __iter__ method? (fwd)

Expand Messages
  • gzeljko
    Mar 14, 2001
      [ Guido van Rossum :]
      > > > We *could* add <next> sniffing, but I believe then we would have to
      > > > 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 an
      > iterator. It could be any old callable.

      Maybe we can use some atribute only for taging iterator.
      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__).

    • Show all 12 messages in this topic