On Tue, Apr 23, 2002, Michael Gilfix wrote: > > Has there ever been a discussion about some easy or straight-forward > way of sharing a global instance across modules? For example, in a > gui app, you might want to structure the program such that there's a > global instance app (main.app) of the application that other modules > might want to query. I was never to happy with importing main and then > using main.app... I felt like I wanted to qualify it as a global, like: > > from main import global app The simple way to do it, IMO, is to import a joint module, called something like cfg. I just did a little hack in a script with cfg = imp.new_module('cfg') but I don't know how well that works across modules. I think you'd need to poke it into sys.modules in order for it to be shared, but I haven't tested it. -- Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/ What if there were no rhetorical questions?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4