Steven D'Aprano wrote: > On Tue, 23 Nov 2010 11:36:05 +0100, Ulrich Eckhardt wrote: >> PS: I've been trying a few things here, and stumbled across another >> thing that could provide a solution. I can "from tests import *", but >> then all these modules will pollute my namespace. I can "import tests", >> but then neither of the submodules will be in "tests". I tried "import >> tests.*", but that doesn't work. Is there no way to import a whole >> package but with its namespace? > > The package needs to know what submodules to make available. Put inside > __init__.py: > > > import foo > import bar > > and then from outside the package, do this: > > import tests > > Now tests.foo and tests.bar will exist.
I've been reading up on packages, but I didn't find anything like that in the documentation, all I found was the meaning of __all__. If I import the modules explicitly there, there's no need to define __all__, unless there are some I don't want to import there, right? Well, I'll try it and see. ;) Steven, thank you for this explanation! Uli -- Domino Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 -- http://mail.python.org/mailman/listinfo/python-list