why _import__ only works from interactive interpreter?

linuxnow at gmail.com linuxnow at gmail.com
Mon May 8 08:58:56 CEST 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

# assign UPPER_CASE vars
for setting in new_settings.keys():
    setting_value = new_settings[setting] # do what you want with the

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

More information about the Python-list mailing list