question about importing a package

Matt matt at
Thu Dec 6 05:58:46 CET 2012

I have a directory structure that looks like this:
sub_one/     # defines only the list    __all__ = ['foo', 'bar']           # defines the function in_foo()           # defines the function in_bar()

In, I have this command at the top:

from sub_one import *

I can't refer to in_foo() and in_bar() without prefacing them with the module names. I.e. foo.in_foo() and bar.in_bar() work, but I want to import them in the __main__ namespace of and refer to them as just in_foo() and in_bar(). I know this is frowned upon, but for my purposes it is the best choice. I have about 30 modules in my package (foos and bars) and I don't want 30 lines at the top of each file that uses this package. What am I doing wrong?



More information about the Python-list mailing list