list comprehension question

Emile van Sebille emile at fenx.com
Sun Mar 24 20:44:44 EST 2002


brueckd at tbye.com
> >>> lo, hi = 1, 3
> >>> [x/2 + 0.1*(x%2) for x in xrange(lo*2, (hi+1)*2)]
>

Which, after only a few moments of inverse re-factorization as per YP*
practice, devolves into:

>>> [round(map(float, [int(x/2) + 0.1*(int(x%2))])[0]*10)/10.
        for x in map(int,xrange(lo*2, (hi+1)*2))]

* something had to come before XP...  ;-)

--

Emile van Sebille
emile at fenx.com

---------




More information about the Python-list mailing list