[Tutor] The case of the missing close

Gonçalo Rodrigues op73418 at mail.telepac.pt
Wed Dec 1 19:07:09 CET 2004

Kent Johnson wrote:

> You have to import cx_Oracle (or any other module) in every module where 
> you use it. Importing a module introduces it into the namespace of the 
> importing module only. (Other than __builtin__) there is no truly global 
> namespace in Python.

Actually there is, the __builtin__ module:

 >>> __builtins__
<module '__builtin__' (built-in)>

And you can stick things inside it too:

 >>> __builtins__.my_own_private_variable = "Hey, I'm a global!"
 >>> def f():
... 	print my_own_private_variable
 >>> f()
Hey, I'm a global!

But after learning this, forget about it: it is a very nice way to shoot 
yourself painful death after painful death.

With my best regards,
G. Rodrigues

More information about the Tutor mailing list