Dennis Lee Bieber wrote: > On 23 Oct 2006 09:45:33 -0700, "Bart Ogryczak" <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > >>The problem is, that then it is not shared. If I do it like that, each >>module has it´s own copy of the cache. Maybe I´m doing something >>wrong. I´ve made a cache module, imported it in each of the >>submodules. I don´t know how to make the data "static". > > > Let me guess... You are using > > from cache_module import * > > to save having to qualify names with "cache_module." > > f-i-* creates local names initially bound to the objects inside a > module, but any "assignment" to such a name later results in the name > being rebound to the new object -- disconnecting from the original. > > import cache_module > > cache_module.some_name = some_object > > maintains the linkage that the name is inside the module, so all other > references that use cache_module.some_name will see the same object.
Note that you can also do import cache_module_with_long_name as cm and then qualify cm to get at the module's attributes, should you have chosen to call your module something inappropriately long. This reduces the typing still further. always-looking-to-avoid-typos-ly y'rs - steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list