PEP-308 a "simplicity-first" alternative
Paul Paterson
hamonlypaulpaterson at houston.rr.com
Thu Feb 13 02:42:50 CET 2003
"Erik Max Francis" <max at alcyone.com> wrote in message
news:3E49FCCB.A44EEBFB at alcyone.com...
> Paul Paterson wrote:
>
> > The form above is spelt slightly different to most because the C is
> > the
> > reverse of most other spellings. In most spellings,
> >
> > x if C else y # x is the norm and is selected if C is true
> >
> > In my form above, x is still the norm (in cases where that has a
> > meaning)
> > but the condition, C, selects the abnormal case, y.
>
> So you're saying that with the form where C is the test expression, x is
> the expression to evaluate if it evaluates true, and y is the expression
> to evaluate it false, then your proposal is
>
> x or y if C
If I read you correct then the answer is no!
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).
val = sqrt(x) or "imag" if x < 0
is the same as,
if x >= 0:
val = sqrt(x)
else:
val = "imag"
Which, if I read you correct above means that I should be saying, "y or x if
C" - I had it this way originally but then switched x and y around because I
realized that my C is really opposite to most people's C. See? <wink>
Ok, so apparently I fail in the "If the implementation is hard to explain,
it's a bad idea." front!
More information about the Python-list
mailing list