loading configuration files that are themselves python
Matthew Vernon
matthew at debian.org
Sat Jul 3 07:10:15 EDT 2010
Peter Otten <__peter__ at web.de> writes:
> Matthew Vernon wrote:
>
> > Is there a more idiomatic way of loading in a configuration file
> > that's python code than:
> >
> > _temp=__import__(path,fromlist='cachestrs')
> > cachestrs=_temp.cachestrs
> >
> > ? I mean, that's pretty ugly...Plain "import" doesn't work in this
> > case because 'path' is a variable defined elsewhere
>
> execfile(path)
>
> in a module with a fixed name that you can import wherever you need access
> to your configuration data?
That looks like what I want, thanks :)
Matthew
--
Rapun.sel - outermost outpost of the Pick Empire
http://www.pick.ucam.org
More information about the Python-list
mailing list