[Python-ideas] Make all keywords legal as an identifier
Westley MartÃnez
anikom15 at gmail.com
Fri Apr 29 00:33:44 CEST 2011
On Mon, Apr 25, 2011 at 09:36:39PM +0200, haael 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
>
> Of course, if a keyword is not preceded by a dot, it would be
> treated as a reserved word, just like now.
> > with = 3 # syntax error
>
>
> There is only one case where a dot is used as a prefix of an
> identifier and that is a relative module import.
> > from .boo import foo
> My change is consistent with this case.
>
>
> One benefit would be that converting current programs to work with
> future versions would be a matter of simple grep.
>
> Python is a great language. In my opinion, this change is the one
> last step to make it every geeky teenager's wet dream: the language
> where one can redefine almost anything. When I work with some
> problem, I always try to translate it to Python, solve and translate
> back. Prohibited identifier names are the main obstacle.
>
> So, let's set the identifiers free and swallow all the world, making
> Python the least common denominator of every computer problem on
> this planet.
>
>
> Regards,
> Bartosz Tarnowski
>
>
>
>
>
I don't know about you guys but I've never needed a reserved word for a
variable name, and if I did, I'd just append an _ to it.
More information about the Python-ideas
mailing list