On Apr 27, 12:42 pm, John Nagle <[EMAIL PROTECTED]> wrote: > Dennis Lee Bieber wrote: > > On 27 Apr 2007 08:34:42 -0700, Paul McGuire <[EMAIL PROTECTED]> > > declaimed the following in comp.lang.python: > > >>deficient - ternary expressions are now part of the language after > >>years of refugees from C and C++ asking how to write "a = b ? c : d", > >>and now they'll get to puzzle/gripe over mapping this to "a = c if b > >>else d". But as a newbie, you need to invest a little more time and > > > And I'll probably ignore those expressions whenever I do get around > > to 2.5+... That syntax, in my mind, just... stinks... > > ALGOL used "expression IF"; you could write > > x := (IF a > b THEN a ELSE b); > > but that doesn't map well to an indentation-based language. > > A syntax suitable for Python, now that there's a bool type, might > be to define ".if()" for "bool". Then one could write > > (a > b).if(a,b) > > which is better than adding an operator. > > Such things are useful in formatting expressions. > > msg = 'Unit is %s' % (unitstatus.if("on","off"),) > > but not really essential. > > John Nagle
I think a big part of the current syntax is that it still supports short-circuiting. In x if a else y y never has to be evaluated if condition a is true. When calling a.if(x,y), both x and y have to be evaluated. -- Paul -- http://mail.python.org/mailman/listinfo/python-list