Re: "dynamical" importing
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: "dynamical" importing

From: Fredrik Lundh <fredrik@pythonware.com>
Date: Wed Oct 19 2005 - 11:37:10 CEST

John Abel wrote:

> def _importModule( moduleName ):
> modName = __import__ ( moduleName )
> modComponents = moduleName.split( '.' )
> for indivComp in modComponents[ 1: ]:
> modName = getattr( modName, indivComp )
>
> return modName

__import__ takes a module name, not an arbitrary file name.

</F>
Received on Mon Oct 24 01:47:31 2005