Loading a file only once into an object and being able to access it from other modules

Philippe C. Martin philippecmartin at sbcglobal.net
Tue Dec 7 10:25:57 EST 2004


This is a basic question I'm sure but I do not know wether to use __builtin__, 
global, or a static method: 

I have a very large XML file that I load into dictionnaries defined in a class 
located in a module that is imported in many places.

Since the loading process is very slow, I would like the file not to be loaded 
on import or class instantiation, but only once (on first import or class 
instantiation).

Currently I have the loading code in the class __init__.


Is there a clean way to do this (I'd like to avoid global)?


Regards,

Philippe


-- 
*********************
Philippe C. Martin
SnakeCard LLC
www.snakecard.com
*********************



More information about the Python-list mailing list