global variable scope
Ian Bicking
ianb at colorstudy.com
Sat Feb 8 18:41:15 EST 2003
On Sat, 2003-02-08 at 16:58, Sam Marrocco wrote:
> Is it possible to make a variable "super-global", meaning that it is
> visible to *all* modules of a python program (I'm well aware of the
> pitfalls to such techniques)?
Well, I believe you can assign values to __builtins__, but it will only
work from the __main__ module. At least, last time I tried fiddling in
such ways that's how I remember it.
If I have functions that, for that application, deserve to be like
builtins, I usually put them in one module and do a "from XXX import
*". For instance, when doing web programming I like to have a function
for escaping HTML available, and I don't like importing every little
function. Doing that one import is much easier to work with than
messing with __builtins__.
--
Ian Bicking ianb at colorstudy.com http://colorstudy.com
4869 N. Talman Ave., Chicago, IL 60625 / 773-275-7241
"There is no flag large enough to cover the shame of
killing innocent people" -- Howard Zinn
More information about the Python-list
mailing list