Single type for __builtins__ in Py3.0

Collin Winter collinw at gmail.com
Fri Sep 23 15:02:00 EDT 2005


On 9/23/05, Fredrik Lundh <fredrik at pythonware.com> wrote:
> Collin Winter wrote:
>
> > As it currently stands, the type of the global __builtins__ differs
> > depending on whether you're in the __main__ namespace (__builtins__ is
> > a module) or not (its a dict). I was recently tripped up by this
> > discrepancy, and googling the issue brings up half-a-dozen or so c.l.p
> > threads where others have been bitten by this, too.
>
> __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.
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.

Collin Winter



More information about the Python-list mailing list