[Tutor] when is a generator "smart?"

bob gailer bgailer at gmail.com
Tue Jun 4 01:15:17 CEST 2013


On 6/1/2013 11:58 PM, Jim Mooney wrote:

>      squarelist = (c**2 for c in range(x,y) if c%2 != 0)

can be simplified to:

squarelist = (c**2 for c in range(x,y,2))

as long as x is odd.

-- 
Bob Gailer
919-636-4239
Chapel Hill NC



More information about the Tutor mailing list