Fredrik Lundh wrote: > Alex Martelli wrote: > >> (there is no common Python type on which you can both call >> len(...) AND the .next() method, for example -- a combination >> which really makes no sense). > >>>> L = [1, 2, 3] >>>> len(L) > 3 >>>> I = iter(L) >>>> I > <listiterator object at 0x0091ABD0> > > (it's probably not a good idea to rely on this behaviour...)
Absolutely not - this has recently been discussed on python-dev, and Guido regrets that __len__ is exposed on any of the built-in iterators. This behaviour may well change in future versions. Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list