For review: PEP 308 - If-then-else expression
holger krekel
pyth at devel.trillke.net
Sun Feb 9 14:05:23 EST 2003
Aahz wrote:
> In article <r8ahfto4.fsf at morpheus.demon.co.uk>,
> Paul Moore <gustav at morpheus.demon.co.uk> wrote:
> >
> >As a follow-on question - does anyone seriously feel that a
> >significant portion of c.l.p is likely to have its opinion swayed by
> >arguments made in this thread?
>
> Not by arguments, no, but by ideas. I believe that the swing voters are
> those who are mildly sympathetic to conditional expressions, but who
> find one or all of the various proposals abhorrent. If someone can come
> up with a truly Pythonic idiom for conditional expressions, I believe
> it'll pass.
that's my guess, too.
> I suspect that my criteria are similar to many other people's:
>
> * must have clear left-to-right or right-to-left meaning
>
> * must look vaguely readable even when abused as the conditional for if
> statements
Maybe Roman Suzi (IIRC) has found one (short-circuiting)
cond -> (true_expr, false_expr)
which i am currently thinking about.
my current pros:
- reads from left to right
- not too easy to abuse, reads rather nicely
- *may* be extended to support dispatching of more than two expr
my current cons:
- the order (true, false) or (false, true) is not obvious
especially if you are converting [false, true](bool(cond))
- the parser might not be taught this grammar (?)
hmmm.
holger
More information about the Python-list
mailing list