[Python-ideas] Make all keywords legal as an identifier

Ronald Oussoren ronaldoussoren at mac.com
Tue Apr 26 12:57:26 CEST 2011


On 26 Apr, 2011, at 9:15, Stefan Behnel wrote:

> Chris Rebert, 26.04.2011 04:45:
>> On Mon, Apr 25, 2011 at 7:35 PM, Steven D'Aprano wrote:
>>> haael wrote:
>>> 
>>>> As I said, I want sometimes to import some non-Python namespace, i.e. a
>>>> Pascal program. If all identifiers are allowed, there would never be a clash
>>>> of reserved words.
>>> 
>>> How do you import non-Python code? I don't understand this argument.
>> 
>> I believe Bartosz is referring to bridges to other languages (e.g.
>> PyObjC), or automatically-generated bindings to non-Python libraries.
> 
> Those won't be helped much by this proposal, though, given that other languages are free to allow or deny as identifiers (and types, objects, closures, references, pointers, ...) whatever they like. Wrapping tools will always have to be aware of both sides of the wrapper, and deal with differences and ambiguities in one way or another. The simple feature that "with" could then be used unmangled in Python code does not even touch the surface of this.

They would be helped because the other language might have method/function/class names that are reserved works in Python, an example of this is the 'class' method of NSObject in Objective-C.

PyObjC using the convention of adding a double underscore to the end of method names to make them valid Python identifiers ( anObject.class__()).

I'm -1 on the proposal though, the readability cost is too high for the very small benifit of using keywords as attribute names.

Ronald

> 
> 
> Stefan
> 
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas




More information about the Python-ideas mailing list