[XML-SIG] [Python-Dev] "xml" package in standard library

M.-A. Lemburg mal at egenix.com
Wed Dec 14 12:17:33 CET 2005

Fred L. Drake, Jr. wrote:
> On Tuesday 13 December 2005 18:40, A.M. Kuchling wrote:
>  > +1; it's what should have been done in the first place.
> If only I'd understood that when I added the xml/PyXML hack to the stdlib 
> years ago.  :-(
> Fixed now.  I'll deal with the documentation in a few days; I actually expect 
> to have some time.

I saw your checkin: wouldn't it be better to keep the xml directory
and xml/__init__.py instead of adding an xml.py module ?

The semantics of a package import are different than that
of a module import, so this may make a difference. I did the
same for the mx packages some years ago (when I moved everything
under the mx package) and then used code like this to make sure
that pickles continued to work as well as have them redirected
to the new package once they were stored again:


# Redirect all imports to the corresponding mx package
def _redirect(mx_subpackage):
    global __path__
    import os,mx
    __path__ = [os.path.join(mx.__path__[0],mx_subpackage)]

# Now load all important symbols
from mx.DateTime import *
from mx.DateTime import __version__

Note that in doing so, pickles will get redirected to the new
package. I'm not sure whether that's what you would want for
the xml/PyXML package, though: it would either direct them
to the xmlcore package (bypassing PyXML on systems where it's
installed) or direct them to the PyXML versions (bypassing
the xmlcore package and causing them only to be unpicklable
on systems with PyXML installed).

Marc-Andre Lemburg

Professional Python Services directly from the Source  (#1, Dec 14 2005)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::

More information about the XML-SIG mailing list