__builtins__
Ben Finney
bignose+hates-spam at benfinney.id.au
Fri Feb 8 20:02:24 EST 2008
LHB <loquehumaine at gmail.com> writes:
> Marc 'BlackJack' Rintsch a écrit :
> > `__builtins__` is an implementation detail, and `__builtin__` is a name
> > of a module you can import. You should not use `__builtins__` but import
> > `__builtin__` and inspect that instead of `__builtins__`.
> Ok. Should I only see `__builtins__` as an access to builtin
> functions/exception/... ?
No, if you want that access, explicitly 'import __builtin__' and
access them that way. Ignore '__builtins__' altogether as an
implementation detail. (This is difficult to adhere to because the
names are confusingly similar; this is an acknowledged wart in current
Python.)
IIRC this behaviour will change in Python 3.0, where 'import
__builtin__' will be the *only* way to get at builtins from normal
code. At least, I'm now writing my code as though that's the case :-)
--
\ “The man who is denied the opportunity of taking decisions of |
`\ importance begins to regard as important the decisions he is |
_o__) allowed to take.” —C. Northcote Parkinson |
Ben Finney
More information about the Python-list
mailing list