Tim Chase <[EMAIL PROTECTED]> writes: > > You could (in 2.5) use: > > [(x if x%2 else 'even') for x in '1234'] > > This failed on multiple levels in 2.3.5 (the "if" syntax is > unrecognized,
Yes, that syntax is new to 2.5. > However, this worked in my 2.3.5: > [((x%2 == 0 and 'even') or x) for x in [-2,-1,0,1,2,3,4]] > It uses the fairly defacto short-circuit-evaluation usage to coin a > Python trinary operator like the C/C++ colon/question-mark pair of > operators. Yeah, you could do that, but there's various drawbacks, hence the new syntax being introduced in 2.5. -- http://mail.python.org/mailman/listinfo/python-list