Missing __length_hint__ in __getitem__ iterator
Giovanni Bajo
raNOsky at deveSPAMler.com
Fri Dec 15 09:44:24 EST 2006
Peter Otten wrote:
> It's there, just not doctored into the dir() output:
>
>>>> class A(object):
> ... def __getitem__(self, index): return index
> ... def __len__(self): return 42
> ...
>>>> iter(A()).__length_hint__
> <built-in method __length_hint__ of iterator object at 0x401d558c>
>>>> iter(A()).__length_hint__()
> 42
>
> Peter
Ah well, actually it's there also in dir(), you just need to use Python 2.5
of course ;)
--
Giovanni Bajo
More information about the Python-list
mailing list