Attitude about new keywords

John Machin sjmachin at
Sun Feb 9 10:31:38 CET 2003

David Eppstein <eppstein at> wrote in message news:<eppstein-2A7B3E.14172808022003 at>...
> In article <7x1y2is9qt.fsf at>,
>  Paul Rubin <phr-n2003b at> wrote:
> > I'd like to ask a meta-question about this: why is adding new keywords
> > something to be so urgently avoided?
> Because it can make previously-working code stop working, when the new 
> keyword happens to match somebody's variable name.

I should preface my questions/remarks by saying that I know nothing
about parsing the Python grammar, nor how restrictive the definition
of "keyword" is.

It is easy to see that what David says is correct, in the case of a
keyword that starts a statement --- a recent example of such a new
keyword would be "yield". This would cause grief for people who had a
variable called "yield" (e.g. the yield on an investment).

However I don't see the problem with introducing "then" as in the
conditional expression "if condition then expr1 else expr2". A
variable name cannot legally appear in that position in Python. If
anyone did have a variable named "then" (far less likely than "yield";
variable names tend to be noun, verb, adjective, and "then" is not one
of these (in English, at least)) cannot the compiler handle the
following, or is it much more difficult?

   then = 1.5
   result = 42 + if some_cond then func1(x) else func2(x)

More information about the Python-list mailing list