"?:", "a and b or c" or "iif"
Andrew Clover
esuzm at bourbon.csv.warwick.ac.uk
Fri May 28 09:18:53 EDT 1999
Robert Meegan (Robert.Meegan at wcom.com) wrote:
> I still don't understand what so many people have against writing simple
> if/else statements.
Although that's fine in this case, where the result of the expression is
assigned to a variable, that doesn't always happen. For example:
selectFlavour(nutAllergy ? strawberry : pistachio)
Would have to be written as:
if nutAllergy:
flavour= strawberry
else:
flavour= pistachio
selectFlavour(flavour)
It think the first version is a lot better, the C-ish ugliness of the symbols
'?' and ':' notwithstanding. Part of the reason is simply that I detest
temporary variables. I want variables to be used to hold varying data and
constants to be used to hold partially calculated values that are used *more
than once* in further calculation. (In a language like Python there is no
particular need for constants and variables to be different in this regard.)
I don't like using variables to hold execution state information.
--
This posting was brough to you by And Clover.
(Sorry.)
More information about the Python-list
mailing list