Single type for __builtins__ in Py3.0

Peter Hansen peter at engcorp.com
Fri Sep 23 18:47:00 EDT 2005


Collin Winter wrote:
> On 9/23/05, Fredrik Lundh <fredrik at pythonware.com> wrote:
>>__builtins__ is a CPython implementation detail.  why not just let it
>>be an implementation detail, and refrain from using it?  it's not that
>>hard, really.

> Given, but I fail to see why it can't be a consistent implementation
> detail. After my own encounter with __builtins__, I now know that I
> should use __builtin__ instead. However, the docs never mention this.

http://docs.python.org/lib/module-builtin.html

> The only way you'd know that __builtin__ is preferred is by searching
> the list archives, something you're not likely to do unless you're
> already having a problem.
> 
> If it's decided to leave things they way they are, at the very least
> the docs should be amended to indicate that users shouldn't be
> touching __builtins__. If anyone has a suggestion as to where this
> kind of thing might best fit (tutorial, library reference, language
> reference?), I'd be happy to write a patch for the docs.

User are clearly told in various places that names with leading and 
trailing double underscores are *special*, and at least by implication 
they are not to be used without a good understanding of what they are. 
You certainly shouldn't have found any docs telling you to use 
__builtins__ that way.

http://www.google.ca/search?q=site%3Apython.org+__builtin__ is a pretty 
quick way of finding the above docs, and while doing the same search 
with __builtins__ admittedly finds lots of mailing list archives where 
people have the same misconception as you did, it doesn't take one past 
the second page of results before you'll be right back at a post by 
Fredrik pointing out the same mistake. :-)

-Peter



More information about the Python-list mailing list