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: John Abel <jabel@plus.net>
Date: Wed Oct 19 2005 - 12:16:33 CEST

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
Received on Mon Oct 24 01:47:41 2005