Demokritos contains some modules that might be useful in other software, so I decided to create a little package for these common modules called 'pyworks' (seeing as that's the umbrella I'm starting to use for my various Python-related projects).
So I was thinking I could rename webbase.py to pyworks.web and call my Subversion library pyworks.svn. I also have a library for helping build domain objects from xml parsing events. I was going to call it pyworks.xml
But that means a 'from svn import repos' in pyworks/svn.py won't work and nor will 'from xml.parsers import expat' in pyworks/xml.py
This problem doesn't exist outside of the pyworks package itself. 'import xml' only means the standard library package and 'from pyworks import xml' gives you the pyworks xml module. Similary with 'import svn' versus 'import pyworks.svn'.
For this reason, I don't mind a little hack internal to pyworks.
I seem to recall the py library (that py.test is in) does something similar.
Unfortunately, calling the module 'pyworks_xml.py' and putting 'import pyworks_xml as xml' in 'pyworks/__init__.py' doesn't work.
UPDATE: The following seems to work in pyworks/__init__.py:
import sys import pyworks_xml sys.modules["pyworks.xml"] = pyworks_xml
UPDATE (2006-02-15): Looks like PEP-328 might be exactly what I need. Another reason I'm looking forward to Python 2.5.