Attitude about new keywords

Ian Bicking ianb at colorstudy.com
Mon Feb 10 04:21:09 EST 2003


On Sun, 2003-02-09 at 08:03, Michele Simionato wrote:
> when condition x else y
> 
> since I thought it was very unlikely somebody was using "when" as a variable
> name. However, a scan of the Python standard library shows that "when" is
> indeed used as an identifier in the tty module. Of course, one could fix
> this by changing when->when_, but it is *very* annoying to have to change
> old code that was perfectly working. Therefore, at this point, I am more
> in the favor of
> 
> x when condition else x
> 
> since "when" could be not made a reserved keyword, just as "as"  in the
> import statement.

I would hate to see "as" become a model for new keywords.  I think "as"
is okay because it can only show up in a very specific place -- in a
certain part of the import statement, and the import statements usually
go right at the top of the file (especially ones that use "as").

But other pseudo-keywords would cause much more difficulty in reading. 
If I see "when" I couldn't use that as an anchor for the expression --
that is, I couldn't read forwards or backwards from that keyword to
understand the rest of the expression.  Instead I'd be forced to find a
different anchor that preceded it and go forward to find the context of
the "when", and thus whether it is a keyword or a variable.

Especially because when is a lame variable name, I don't think it's
worth such a convolution to save it.  But I think I'd feel that way for
almost all keywords.

-- 
Ian Bicking  ianb at colorstudy.com  http://colorstudy.com
4869 N. Talman Ave., Chicago, IL 60625  /  773-275-7241
"There is no flag large enough to cover the shame of 
 killing innocent people" -- Howard Zinn





More information about the Python-list mailing list