On Sun, Dec 2, 2018 at 12:08 PM Greg Ewing <greg.ew...@canterbury.ac.nz> wrote: > class MapView: > def __len__(self): > return min(map(len, self.args)) > > def __iter__(self): > return self > > def __next__(self): > if not self.iterator: > self.iterator = map(self.func, *self.args) > return next(self.iterator)
I can't help thinking that it will be extremely surprising to have the length remain the same while the items get consumed. After you take a couple of elements off, the length of the map is exactly the same, yet the length of a list constructed from that map won't be. Are there any other non-pathological examples where len(x) != len(list(x))? ChrisA _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/