| Store | Cart

Turn off globals in a function?

From: Ron_Adam <rad...@tampabay.rr.com>
Sun, 27 Mar 2005 02:49:00 GMT
>If you put the above def b in e.g. a_module.py,>and do a (untested ;-)>>    from a_module import b>>instead of defining it locally, then the global references>from b (and whatever else you import from a_module)>should be to the global dict defined for a_module (i.e., its>outermost scope),  not to the globals where you do the import.>>>y = True>>>>>>>a(False):>>True>Should work if you define a in place having same scope as the y assignment>>>>>>>b(False):>>*** name error here ***>>>UIAM it should do this if you import b as above.>>Regards,>Bengt Richter

Good suggestion. Thanks. I was somewhat aware of the modular scope,
but was looking for way to apply it on a more local level. Michael's
suggestion looks interesting for that.

Ron_Adam

Recent Messages in this Thread
Ron_Adam Mar 26, 2005 08:01 pm
Michael Spencer Mar 26, 2005 08:18 pm
Bengt Richter Mar 26, 2005 09:02 pm
Ron_Adam Mar 27, 2005 02:49 am
Oren Tirosh Mar 27, 2005 06:51 am
Ron_Adam Mar 27, 2005 04:45 pm
Greg Ewing Mar 31, 2005 04:28 am
Ron_Adam Mar 31, 2005 05:31 pm
Ron_Adam Mar 27, 2005 02:13 am
Messages in this thread