loading configuration files that are themselves python

Terry Reedy tjreedy at udel.edu
Sat Jul 3 15:02:16 EDT 2010


On 7/3/2010 5:15 AM, Matthew Vernon wrote:
> Hi,
>
> 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

cachestrs=__import__(path,fromlist='cachestrs').cachestrs
?

-- 
Terry Jan Reedy




More information about the Python-list mailing list