
On Mon, Apr 25, 2011 at 3:36 PM, haael <haael@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.
This is exaggeration, but the point is well-taken.
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. You do not prevent this with your suggestion.
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 I don't see how this is a real improvement over the current convention, to add a trailing underscore, so that programs really needing to use the name "with" would use "with_". This does not introduce any new syntax and maintains the same level of backwards comparability your suggestion does.
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. (This isn't actually true.)
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
Mike