Proposed new syntax

Ned Batchelder ned at nedbatchelder.com
Fri Aug 25 07:07:04 EDT 2017


On 8/25/17 12:10 AM, Paul Rubin wrote:
> Steve D'Aprano <steve+python at pearwood.info> writes:
>> Did __next__ cache the most recently generated value?
> No but if they're going to change stuff, they might as well actually
> improve it instead of just renaming it to break code gratutiously.

The vast majority of iteration has no need for the last-returned value
again, so why add it to every iteration? You can provide it yourself (or
propose it!) with a small wrapper class.  One of the beautiful things
about Python's iteration model is that it does just one thing well. 
This means it can be applied in more situations to more kinds of data. 
Then if you need more, you build on top of it.

--Ned.




More information about the Python-list mailing list