PEP-308 a "simplicity-first" alternative

Paul Paterson hamonlypaulpaterson at houston.rr.com
Wed Feb 12 23:31:13 EST 2003


"Erik Max Francis" <max at alcyone.com> wrote in message
news:3E4AFA7B.C179CDB3 at alcyone.com...
> Paul Paterson wrote:
>
> > The form is best shown by example since the x, y, C nomenclature can't
> > be
> > written with all the symbols meaning the same thing as in your other
> > examples (which is why I goofed and switched the spelling of x and y
> > between
> > posts).
>
> Uh, why can't they?  C is the conditional test, x is the expression to
> evalute if it is true, y is the one to evaluate if false.  Whether or
> not you're crazy about the choice of symbols, that is utterly
> unambiguous.
>

Using your definitions it's not ambiguous but it can be misleading since, in
all other forms I recall seeing, C is the conditional test to select the
normal or primary value. Hence a quick reading of "y or x if C" might lead
you to believe that x is intended to be the normal result.

> > val = sqrt(x) or "imag" if x < 0
> >
> > is the same as,
> >
> > if x >= 0:
> >     val = sqrt(x)
> > else:
> >     val = "imag"
>
> So your proposal is
>
> y or x if C

It is!






More information about the Python-list mailing list