Could someone provide me with a good way of importing a whole directory of modules? I have a structure like this:
/Foo bar.py spam.py eggs.py
This is the best way i've found so far:
from os.path import dirname, join, isdir, abspath, basename from glob import glob pwd = dirname(__file__) for x in glob(join(pwd, '*.py')): if not x.startswith('__'): __import__(basename(x)[:-3], globals(), locals())