Subclassing int for a revolving control number

Matteo Dell'Amico della at toglimi.linux.it
Tue Jul 20 18:06:52 CEST 2004


Stephen Ferg wrote:
> I think the simplest solution would be just to use a generator...
> 
> ************************************
> def rollover(argMaxNumber=20):
> 	while True:
> 		for i in range(1, argMaxNumber+1):
> 			yield i

This can also be spelled as itertools.cycle(xrange(max_number)).

-- 
Ciao,
Matteo



More information about the Python-list mailing list