[Python-ideas] Make all keywords legal as an identifier
Mike Graham
mikegraham at gmail.com
Mon Apr 25 22:05:52 CEST 2011
On Mon, Apr 25, 2011 at 3:51 PM, Brian Curtin <brian.curtin at gmail.com> wrote:
> On Mon, Apr 25, 2011 at 14:36, haael <haael at interia.pl> wrote:
>>
>> Hello, guys.
>>
>> I did post this idea a few months ago. Now the revised version.
>>
>>
>> Goal:
>> Let _all_ alphanumeric keywords be legal as names for variables, functions
>> and classes, even the ones that are reserved words now.
>>
>> Rationale:
>> 1. Python took most good English words as reserved tokens. Situation goes
>> worse from version to version. I often have hard time searching for
>> acceptable synonyms.
>> 2. Because of that, old Python programs cease to work, even if they do not
>> use any abandoned features. Their only sin is using certain words that
>> further versions of Python have stolen away.
>> 3. Sometimes one needs to import keywords from some other language, XML be
>> an example, or "translate" another programming language into Python in one
>> way or another. Keyword reservation is a big problem then; it does not allow
>> to use the natural Python syntax.
>>
>> Solution:
>> Let the parser treat all keywords that come after a dot (".") as regular
>> identifiers.
>>
>>
>> For attributes, nothing changes:
>> > boo.for = 7
>>
>> For names that are not attributes, only one syntax change is needed: let a
>> dot precede any identifier.
>> > .with = 3
>
> Names tend to be nouns, so first I can't imagine why you'd want "with" as a
> name, but you could exchange almost all keywords in the example and it's not
> a great case. Making this change rather than working around poor name choice
> gets a -1 from me.
To nitpick, names don't tend to be nouns only. Names of functions and
methods tend to be verbs and names of interfaces and abstract classes
are sometimes adjectives.
M
More information about the Python-ideas
mailing list