By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,645 Members | 1,065 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,645 IT Pros & Developers. It's quick & easy.

Using the __builtins__ module to assign new global variables

P: n/a
Hi,

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
modules.

For example.

#/ main file

class Test: pass

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

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

Thanks.
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Opinder wrote:
Are there any side effects in assigning new variables to the
__builtins__ module for the purpose of exposing variables to imported
modules.


Generally, Guido frowns at you very sternly. Also, you could
cause a disaster if there is a conflict between your idea of what
should be a global and some other module's idea. You will be in
big trouble if a builtin is added that you over-write (actually
a form of the same problem).

--
-Scott David Daniels
Sc***********@Acm.Org
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.