"?:", "a and b or c" or "iif"
Paul Duffin
pduffin at mailserver.hursley.ibm.com
Fri May 28 12:25:40 EDT 1999
Robert Meegan wrote:
>
> On Fri, 28 May 1999, Andrew Clover wrote:
>
> >
> > 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)
> >
>
> Actually, I would have written it:
>
> if nutAllergy:
> selectFlavour(strawberry)
> else:
> selectFlavour(pistachio)
>
> without any temporary variables.
>
Of course when you have multiple options to choose you have to
use temporary variables.
> To be really precise, I would have spelled it selectFlavor like a proper
> English speaker <grin>.
>
You mean like a proper *** US *** English speaker :)
--
Paul Duffin
DT/6000 Development Email: pduffin at hursley.ibm.com
IBM UK Laboratories Ltd., Hursley Park nr. Winchester
Internal: 7-246880 International: +44 1962-816880
More information about the Python-list
mailing list