> > foo = x and y or z > > > > is much less elegant than > > > > foo = x ? y : z > > You must be joking too... You think that > > x and y or z > > is as clear as > > x ? y : z
I think its clearer! It says that the first two things happen or else the last thing. Plain English. '?:' means absolutely nothing without somebody to explain it. > Ugly as I think it is, I could live with that. But it's worse: > > x and y or z > > doesn't even work if y evaluates to False. Sure I wasn't recommending that and/or is a good idea I just meant that ugly as it was it was clearer than the meaningless ?: > As far as I'm concerned, the lack of a proper ternary if/then/else > operator is a wart in the otherwise very clean design of Python. The > lack of a switch statement too, but to a much lesser degree. Interesting, obviously a lot of support for both, yet they are features I try to avoid in C(*) and never miss in Python. If given the choice I'd much rather have decent lambdas or even a repeat/until loop! (*)And most software houses I've worked with have ternary operators on their "do not use" list along with switch fall-throughs. BTW I do confess that if switch exists I will use it where I can't use OOP or a dictionary to avoid it - like in vanilla C...! Alan G. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor