Eric S. Johansson wrote: > I have a collection of packages and I want to put them under single > unifying name. my goal is to reduce namespace pollution and make all > these packages accessible as 'import vvv.aaa'. In more detail, if I have > packages 'aaa' and 'bbb', what do I do to put those packages under > unifying name such as 'vvv'? the only way I can see to do it is to > create 'vvv' as a directory with its own __init__.py but I'm not sure > that were work right either. > > > thanks. >
I don't see why it would be a problem: py> import os py> for afile in os.listdir('pypack'): ... if not afile.endswith('pyc'): ... print '# %s' % afile ... print open(os.path.join('pypack', afile)).read().strip() ... print '# end of file\n\n' ... # __init__.py from mod1 import x from mod2 import y # end of file # mod1.py x = 14 # end of file # mod2.py y = 42 # end of file py> import pypack py> dir(pypack) ['__builtins__', '__doc__', '__file__', '__name__', '__path__', 'mod1', 'mod2', 'x', 'y'] py> pypack.mod1 <module 'pypack.mod1' from 'pypack/mod1.py'> James -- http://mail.python.org/mailman/listinfo/python-list