Pyworks Common Library and Import Issues

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 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/ won't work and nor will 'from xml.parsers import expat' in pyworks/

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 '' and putting 'import pyworks_xml as xml' in 'pyworks/' doesn't work.

UPDATE: The following seems to work in pyworks/

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.

The original post was in the categories: python pyworks but I'm still in the process of migrating categories over.

The original post had 1 comment I'm in the process of migrating over.