For review: PEP 308 - If-then-else expression
Andrew Koenig
ark at research.att.com
Sat Feb 8 09:53:20 EST 2003
Anthony> Why not simply:
Anthony> def condsqrt(z):
Anthony> if z > 0.0:
Anthony> return sqrt(z)
Anthony> else:
Anthony> return 0.0
Anthony> y = [ condsqrt(z) for z in x ]
Anthony> There's a function call overhead, but it's a hell of a lot
Anthony> easier to read.
I'm not convinced it's easier to read, because I must now look in
two different places to see what's going on.
--
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark
More information about the Python-list
mailing list