Adding objects to __builtins__

M

Matteo Merli

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:
.... print "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
 
P

Peter Hansen

Matteo said:
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:

Does this help?
Traceback (most recent call last):

By the way, you *really* shouldn't use this as a "convenient"
way of getting global variables or other things around to your
various modules. That would be almost the worst thing for
code maintainability that you could do. You'll come to hate
yourself for doing it, down the road.

There are some valid use cases for doing such a thing, but
sticking just any old function in there is not it.

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top