[Python-Dev] Python keywords (was Lockstep iteration - eureka!)

Guido van Rossum guido@beopen.com
Wed, 09 Aug 2000 19:12:59 -0500


> [Skip laments...]
> > Could this be extended to many/most/all current instances of
> > keywords in Python?  As Tim pointed out, Fortran has no
> > keywords.  It annoys me that I (for example) can't define
> > a method named "print".
> 
> Sometimes it is worse than annoying!
> 
> In the COM and CORBA worlds, it can be a showstopper - if an external
> object happens to expose a method or property named after a Python keyword,
> then you simply can not use it!
> 
> This has lead to COM support having to check _every_ attribute name it sees
> externally, and mangle it if a keyword.
> 
> A bigger support exists for .NET.  The .NET framework explicitly dictates
> that a compliant language _must_ have a way of overriding its own keywords
> when calling external methods (it was either that, or try and dictate a
> union of reserved words they can ban)
> 
> Eg, C# allows you to surround a keyword with brackets.  ie, I believe
> something like:
> 
> object.[if]
> 
> Would work in C# to provide access to an attribute named "if"
> 
> Unfortunately, Python COM is a layer ontop of CPython, and Python .NET
> still uses the CPython parser - so in neither of these cases is there a
> simple hack I can use to work around it at the parser level.
> 
> Needless to say, as this affects the 2 major technologies I work with
> currently, I would like an official way to work around Python keywords!

The JPython approach should be added to CPython.  This effectively
turns off keywords directly after ".", "def" and in a few other
places.

--Guido van Rossum (home page: http://www.pythonlabs.com/~guido/)