On 2 avr, 21:07, Brian Munroe <[EMAIL PROTECTED]> wrote: > On Apr 2, 11:04 am, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > > > More seriously: the answer is in the > > doc.http://www.python.org/doc/2.3.5/lib/built-in-funcs.html > > > read about the __import__ function, experiment in your interactive > > python shell, and you should be done in a couple minutes. > > Well, If I understand the docs correctly, that would work great if > backends/ was a module and not a package?
Not necessarily. > I need to keep backends/ > system1/ and backends/system2 as separate directory structures to make > things fairly isolated from each other (for neatness sake) > > Currently I'm building the backends/__init__.py __all__ list > dynamically, such as: > > backends/__init__.py > -------------------- > > import os > > __all__ = [] > > for module in os.listdir(__path__[0]): > if not module.startswith("__"): > __all__.append(module) Why not do the import here, so you store a real module instead of a name ? ie (not tested): for module_name in os.listdir(__path__[0]): if not module_name.startswith("__"): __all__.append(__import__(module_name, globals(), locals())) My 2 cents... -- http://mail.python.org/mailman/listinfo/python-list