why _import__ only works from interactive interpreter?
linuxnow at gmail.com
linuxnow at gmail.com
Mon May 8 02:58:56 EDT 2006
Sorry to follow up myself, I've finally used the execfile approach,
passing an empty dict for capturing locals and then just processing it:
new_settings = {}
execfile(self.SETTINGS_MODULE, new_settings) # returns its locals in
new_settings
# assign UPPER_CASE vars
for setting in new_settings.keys():
setting_value = new_settings[setting] # do what you want with the
vars
It looks like a better solution than polluting the namespace and allows
to use any file as a config file withou the need to have it on
sys.path.
More information about the Python-list
mailing list