How do I import everything in a subdir?
chrisdewinN0SPAM at yahoo.com.au
Sun Mar 6 06:20:42 CET 2005
I have a program which I want a plugin directory for. I figured the way to
go about that would be to just add a plugin/ dir to sys.path, and import
everything in it. Then my program can just execute the main() method of
each imported plugin.
Is that a good way to go about it?
If so, how do I import everything in the plugins dir? The method raises an
error as you can see.
>>> import sys
>>> import os
>>> ls = os.popen("ls plugins").readlines()
>>> for x in ls:
>>> for x in plugs:
... import x
Traceback (most recent call last):
File "<stdin>", line 2, in ?
ImportError: No module named x
More information about the Python-list