Adding objects to __builtins__

Matteo Merli matteo.merli at studenti.unipr_punto_it
Wed Jun 2 13:34:01 EDT 2004


Hi, 
is there a way to save objects in the __builtins__ namespace? 
the goal is to make them available in all the modules of my app, without
reimporting all the things and keep references...

The curious thing is that when i try from the interactive interpreter the
thing just works:

>>> def a():
...     print "ciao"
...
>>> a()
ciao
>>> __builtins__.b = a
>>> b()
ciao
>>>

But i've tried inside a script, recalling objects from other imported
modules, they cannot see them.
Does exist a way to do this, or is just a stupid thing?

Thank you
matteo merli




More information about the Python-list mailing list