"dynamical" importing

Fredrik Lundh fredrik at pythonware.com
Wed Oct 19 05:37:10 EDT 2005


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> 






More information about the Python-list mailing list