advanced listcomprehenions?

Duncan Booth duncan.booth at invalid.invalid
Fri Jun 20 03:31:19 EDT 2008


Terry Reedy <tjreedy at udel.edu> wrote:

>> [['Fizz', 'Buzz', 'FizzBuzz', str(i)][62/(pow(i, 4, 15) + 1)%4] for i
>> in xrange(1, 101)]
> 
> These make the lookup table variable, so it has to be recalculated for
> each i.
> 
So what? Mark Wooding was posting about mathematical elegance and came up 
with that really neat pow() call. If runtime came into it then one of the 
previous solutions or (as Mark already said) a straightforward sometable[i%
15] is going beat something like this hands-down.

This is coding for fun not profit.

-- 
Duncan Booth http://kupuguy.blogspot.com



More information about the Python-list mailing list