Proposed PEP for a Conditional Expression
thp at cs.ucr.edu
thp at cs.ucr.edu
Sun Sep 16 22:42:38 EDT 2001
thp at cs.ucr.edu wrote:
: James_Althoff at i2.com wrote:
: : Marcin Kowalczyk wrote:
: :> abs = if x>=0 then x else -x
: :>or
: :> abs = if x>=0: x else: -x
: :>looks more readable than
: :> abs = cond(x>=0, lambda:x, lambda:-x)
: :>for me.
: : That's a fair opinion. But you have to admit that the last one beats the
: : heck out of the first two in terms of implementation issues.
: As far as I can tell, it doesn't work if x is a local variable. Have
: you actually tried it?
Oops! I failed to note that you were presuming nested scopes.
Tom Payne
More information about the Python-list
mailing list