Using the __builtins__ module to assign new global variables

Opinder osbhella at
Mon Mar 1 22:48:06 CET 2004


For the Python experts out there:

Are there any side effects in assigning new variables to the
__builtins__ module for the purpose of exposing variables to imported

For example.

#/ main file

class Test: pass

mytest = Test()  #/ instance of a class
__builtins__.mytest = mytest

import abc

#/ -----------------------
#/ This is the module file
#/ This should work because of the __builtins__ above
print mytest 


More information about the Python-list mailing list