"dynamical" importing

John Abel jabel at plus.net
Wed Oct 19 06:16:33 EDT 2005


Fredrik Lundh wrote:

>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> 
>
>
>
>  
>
Didn't mean to imply that it did.  By pathToModule, I meant spam.ham as 
in 
http://localhost/documentation/Python-Docs-2.4.1/lib/built-in-funcs.html#l2h-6 
( hopefully, that should explain things to the OP ).

J



More information about the Python-list mailing list