Library package import question

Frank Aune Frank.Aune at
Mon Nov 5 14:34:26 CET 2007


I have a python library package 'Foo', which contains alot of submodules:

		class Bar()
		class Hmm()
		class Bee()
		class Wax()
		etc etc

To prevent namespace pollution, I want to import and use this library in the 
following way:

import Foo
t = Foo.module2.Bee()

To accomplish this, I put explicit imports in

import module1
import module2
import module3

what Im wondering about, is if its a more refined way of doing this, as the 
explicit imports now need to be manually maintained if the library grows. 
I've tried to use __all__, but this only seems to work with "from Foo import 
*" and it causes modules to be imported directly into the namespace of 

Thanks for input.

More information about the Python-list mailing list