[Python-de] include von config-files

Georg Mischler schorsch at schorsch.com
Di Aug 14 20:35:19 CEST 2007


Georg Brandl wrote:

> Roland M. Kruggel schrieb:
> > Hallo Liste,
> >
> > kann ich einen, z.b. Konfigurationsfile, mit include laden der nicht
> > die endung .py hat und z.b. im /etc liegt?
>
> Dazu empfehle ich execfile().

execfile() startet einen neuen Prozess, was den Zugriff auf die
geladenen Konfigurationsinformationen etwas umständlich macht...

Für die Problemstellung wird normalerweise __import__() verwendet.
  http://docs.python.org/lib/built-in-funcs.html#l2h-6


-schorsch

-- 
Georg Mischler  --  simulations developer  --  schorsch at schorsch com
+schorsch.com+  --  lighting design tools  --  http://www.schorsch.com/




Mehr Informationen über die Mailingliste python-de