I was putting this idea How to make a cross-module variable? in action for python3.
And was lazy enough to use the variable __builtins__
instead of the module builtins
. Which should make no difference because:
# file spam.py:
import builtins
print (builtins is __builtins__)
print (id(builtins))
print (id(__builtins__))
This is when it gets funny: builtins
is not __builtins__
when imported:
$ python3 spam.py
True
140598001743336
140598001743336
$ python3 -c 'import spam'
False
139755426543080
139755426520904
Does anyone know what happens?
(A comment on the given page mentions "__builtins__
is a CPython peculiarity, you really shouldn't use it", but I'm being curious...)