[Python-Dev] [poll] New name for builtins (original) (raw)
Terry Reedy tjreedy at udel.edu
Fri Nov 30 00:12:53 CET 2007
- Previous message: [Python-Dev] [poll] New name for __builtins__
- Next message: [Python-Dev] [poll] New name for __builtins__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Guido van Rossum" <guido at python.org> wrote in message news:ca471dc20711290954v173cf2ebx9427de211ba9afbd at mail.gmail.com... | But then I thought, what if we renamed the builtin module instead | to builtins, and left builtins alone? || In Python 0.1, builtin was called builtin, and I think the | reason for renaming it wasn't particularly well thought-out; as a | module, I'm not sure that it really needs to have such a special | name (I don't think it's more special than sys, anyway). There's no | motivation in the checkin comment that renamed it (r3527).
+1 for plain 'builtins' or whatever for the name of the module. I believe it would have been less confusing to me learning Python, (and still today ;-) if it had been this way 10 years ago.
The rationale for special xxx names (identifiers) is to avoid namespace clashes. So they are only needed for namespace names bound to objects, including string objects representing definition names. Since 'builtin' is merely a string object bound to 'name' (I presume) in the module itself and to 'builtins' in all others, a string that did not imitate a reserved identifier would be clearer, at least to me.
Similarly, by the way, the main module might justifiably be 'name'ed 'main' rather than 'main' since whatever string is bound to 'name' is not in the module namespace. "if name == 'main' " is a bit easier to type and to me a bit clearer. The only problem would be if someone put the incantation into a non-main module named 'main.py', but the same is true today of 'main.py'. And I would consider either a buggy practice.
These are the only two builtin strings I can think of that have the form of special names, even though they are not actually identifiers. If so, they are the only two 'special names' that must be quoted as strings, while binding names (identifiers) usually are not. If both were changed, then 'special names' would simply be 'internal namespace names used by the implementation'. I think this would make it easier for beginners to keep separate the notions of 'identifier' and 'string'.
Terry Jan Reedy
- Previous message: [Python-Dev] [poll] New name for __builtins__
- Next message: [Python-Dev] [poll] New name for __builtins__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]