importing / loading a module / class dynamically

hg hg at nospam.org
Fri Jan 5 05:15:28 EST 2007


Laszlo Nagy wrote:

> 
>> Thanks,
>>
>> What I am doing is adding plugin support to PyCrust ... so I'm looking
>> for a mechanism where anyone can develop a plugin and have it loaded by
>> pycrust.
>>
>> the .py was a typo
>>
>>
>> why the "...Have at least an empty plugin/name1/__init__.py file..." ?
>>   
> When you do
> 
> import plugins.name1.name1
> 
> then "plugins" and "plugins/name1" should be a package, not a module. A
> package is a special directory that contains package initialization code
> in a __init__.py file. If you do not have the file, then the "plugins"
> directory will be only a directory, and it cannot be imported.
> 
> For details, see:
> 
> http://docs.python.org/tut/node8.html#SECTION008400000000000000000
> 
>   Laszlo


Many thanks Laszlo, it looks like I got it to work ... result will be on
www.snakecard.com/PY for those interested ... in the next few days

hg





More information about the Python-list mailing list