PEP 308: Alternative conditional operator forms

Michele Simionato mis6 at pitt.edu
Fri Feb 14 10:31:26 EST 2003


Nick Vargish <nav at adams.patriot.net> wrote in message news:<yyyadgzgav0.fsf at adams.patriot.net>...
> mis6 at pitt.edu (Michele Simionato) writes:
> 
> > I tested the proposed syntax showing it to my girlfriend (see the
> > thread on usability studies). She is an happy non-programmer  [...]
> 
> I really enjoyed your post about your girlfriend's reactions to
> various constructs, but I took it more as humor than as a serious
> attempt at a usability study. As humor, it was excellent.

Yes, actually it was intended as humor. I would not take her as a
language designer ;-). Nevertheless, Tim Peters explicitly said in
that
thread that Guido is sensitive to this topic (easy of understanding
from beginners having Python as first language).

Now my point is: if we have two forms with the same functionality,
should the choose the form that makes sense for experienced
Pythonistas
only, or the form accessible to everybody?

The real reason why I am against (if C: x else: y) is (as I repeated
many
times) that I want to keep the difference between statement and
expressions.

When I started programming in Python, I regarded that distinction as
a bad thing, and I thought languages where everything is an expression
(including the assignement) were superior.

Now I have changed my mind since I think I have understood why Guido
made this distinction: the reason is *indentation*.

Since "if" is a statement, you are forced to indent it correcly; if
"if"
becomes an expression, indentation is no more significant:

(if C:

            x else: (if C2: 
z else: y))

would be valid. 

Of course, you could say that this is bad style and that
people should indent correctly: but I want people to be *forced* to
indent
correctly. In my view, forced indentation is the more pythonic of the
Python virtues, and I want to keep it if I can. If everything becomes
an
expression, indentation will become completely random. 

I realize that this can be an issue or not depending on the personal
taste. I like Python because of the forced indentation, maybe you find
forced indentation annoying. In this case we should simply agree to
disagree.


                                 Michele




More information about the Python-list mailing list