itertools.ilen?
Jeremy Fincher
fincher.* at osu.edu
Thu Aug 7 06:11:10 EDT 2003
Michael Peuser wrote:
> There is no way to determined, whether such generartors will come to an
> end - The Halting Problem for Turing Machines ;-)
> Thus there will never be a safe len(iterator).
But then, there's no way to determine whether any given class' __len__ will
terminate, so you've got the same problem with len.
Granted, it's more likely to manifest itself with iterators and ilen than
with sequences and len, but if it's really an issue, ilen could take an
optional "max" argument for declaring a counter ilen isn't to exceed.
Jeremy
More information about the Python-list
mailing list