PEP 308: Alternative conditional operator forms

Michele Simionato mis6 at pitt.edu
Tue Feb 11 10:16:03 EST 2003


Nick Vargish <nav at adams.patriot.net> wrote in message news:<yyy4r7big79.fsf at adams.patriot.net>...
> Erik Max Francis <max at alcyone.com> writes:
> 
> > What else should be on this list?  (You can reply by email if you wish.)
> 
> It requires a new keyword, but how about
> 
> C then x else y
> 
> with the else clause being mandatory. Alternately
> 
> C then: x else: y
> 
> As far as possible new keywords go, I'll guess that 'then' is not
> commonly used as a variable name. I expect this will get shot down,
> though -- I've noticed a certain resistance to the addition of new
> keywords.
> 
> What I'd really like is to have the conditional come first, and avoid
> overloading the 'if' keyword. Obviously else is already overloaded,
> and fits nicely in context.
> 
> Nick

I was thinking to this possibility (without the colons). 
Notice that "then" could be a pseudo-keyword analogous to "as". I
would support this more than

(if C: x else: y)

that I dislike since

1) overload "if"
2) it is too much similar to a statement.

In the last few days I have changed my mind and now I am against any
suggestion than could generate confusion between the "if" statement and
the conditional expression. This is because somebody pointed out the confusion
between

if C: print x
else: print y

(valid code)

and

(if C: print x
 else: print y)

invalid code!

                              Michele




More information about the Python-list mailing list