Attitude about new keywords

Paul Rubin phr-n2003b at NOSPAMnightsong.com
Sat Feb 8 17:11:54 EST 2003


Michele Simionato writes about the ternary operator proposals:

     2. If we want a Pythonic (i.e. readable) ternary operator that even
        newbies can understand, we have to pay a price: add a new kewyword
        or new punctuation.

I'd like to ask a meta-question about this: why is adding new keywords
something to be so urgently avoided?  In natural languages, messing
with the syntax is a big deal, but adding new words to the vocabulary
is done all the time.

In fact I'd say Python could use quite a few new keywords, where it
currently uses __xxx__ variables.  People often compare Python's
indentation to Lisp's parentheses as the "initially annoying feature
that you learn to love".  But I'd say __ is more in that category.

Examples: IMO,

1. in a class definition,

      class foo(object):
            __slots__ = ['name', 'address', 'zip]

    would be better as

         class foo(object):
            slots: name, address, zip


2.  At the beginning of a module,

      __all__ = ['frob', 'mung', 'squibble']

    would be better as

       export frob, mung, squibble

3. __metaclass__ could be replaced by a "keyword arg" in the superclass list:

   class Polygon (Shape, metaclass=Drawable)

There are several more like this that I'm not thinking of right now.




More information about the Python-list mailing list