[Python-ideas] __len__() for map()
Jonathan Fine
jfine2358 at gmail.com
Mon Nov 26 17:14:58 EST 2018
Hi Kale
Thank you for the sample code. It's most helpful. Please consider
>>> it = iter(range(4))
>>> list(map(float, it))
[0.0, 1.0, 2.0, 3.0]
>>> it = iter(range(4))
>>> list(zip(it, it))
[(0, 1), (2, 3)]
>>> list(zip(range(4), range(4)))
[(0, 0), (1, 1), (2, 2), (3, 3)]
A sequence is iterable. An iterator is iterable. There are other
things that are iterable. A random number generator is an iterator,
whose underlying object does not have a length.
Briefly, I don't like your suggestion because many important iterables
don't have a length!
--
Jonathan
More information about the Python-ideas
mailing list