generator object or 'send' method?

Terry Reedy tjreedy at udel.edu
Tue Feb 10 23:02:44 CET 2009


Aaron Brady wrote:

> I guess a generator that counts, but skips K numbers, where K can be
> varied.  For instance, you initialize it with N, the starting number,
> and K, the jump size.  Then, you can change either one later on.

This specification is incomplete as to the timing of when changes to N 
take effect and when variable K is applied.

> This gets two birds with one stone, but is it possible?

If you write an iterator class instead of trying to stretch the 
abbreviated form beyond its intention, and the specification is 
coherent, it should be trivial.




More information about the Python-list mailing list