On Sat, Dec 1, 2018, 11:54 AM Steven D'Aprano <st...@pearwood.info wrote:
> # current behaviour > mo = map(lambda x: x, "aardvark") > list(islice(mo, 3)) # discard the first three items > assert ''.join(mo) == 'dvark' > => passes > > # future behaviour, with your proposal > assert ''.join(mo) == 'dvark' > => fails with AssertionError > > Given the certainty that this change will break code (I know it will > break *my* code, as I often rely on map() being an iterator not a > sequence) it might be better to introduce a new "mapview" type rather than > change the behaviour of map() itself. On the other hand, since the fix is > simple enough: > > mo = iter(mo) > Given that the anti-fix is just as simple and currently available, I don't see why we'd want a change: # map->sequence mo = list(mo) FWIW, I actually do write exactly that code fairly often, it's not hard. >
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/