Py3K idea: why not drop the colon?

Dan Lenski dlenski at gmail.com
Sat Nov 11 20:30:18 EST 2006


Hendrik van Rooyen wrote:
> "Fredrik Lundh" <fredrik at pythonware.com> wrote:
>
> 8<---------------------------------------------------
> >  >>> color = "blue"
> >  >>> if color == "red" or "green" or "yellow":
> > ...     print color, "is red or green or yellow"
> > ...
> > blue is red or green or yellow
>
> *grin* - this can be construed as a weakness in Python -
>
> Even COBOL compilers in the sixties would "add in" the implied
> "if color = " after each 'or', instead of bloody - mindedly thinking:

How the heck could this be considered a weakness in Python?  I *like*
the fact that Python does not do anything "automagical" and rewrite
expressions, thinking it's smarter than the programmer.  That's one
reason I got sick of Perl.

There are plenty of cases where I might want to use an expression like
"color == red or foo or bar" with the semantics it actually implies in
Python.  Making an exception for literal strings specifically seems
reallly dubious given the fact that Python already has an easy way to
do what you want with the "color in (red, green, blue)" construct.
This supposedly lacking feature would only be desired by people who
have been brain-damaged by programming languages like BASIC and
COBOL... or newbies who haven't programmed enough to really "get"
Boolean logic.  </rant>

Dan




More information about the Python-list mailing list