[Python-Dev] ElementTree - Why not part of the core? (fwd)
Fredrik Lundh
fredrik at pythonware.com
Mon Dec 12 12:14:33 CET 2005
Martin v. Löwis wrote:
> > Since all the relevant module names start with "Element", putting it directly
> > under xml wouldn't be too bad. But an xml subpackage is better, and prior
> > art says "etree".
>
> So etree it is.
I just realized that the prior art (lxml.etree) uses etree as an alias for the
ElementTree module, not as a package name. this means that to import the
core Element type, you'd do:
# classic ET
from elementtree.ElementTree import Element
or
# bundled ET
from xml.etree.ElementTree import Element
or
# libxml-powered ET
from lxml.etree import Element
or
# accelerated ET
from cElementTree import Element
I'm not sure if this really is a problem. better explicit than implicit, as PyXML
has shown us. if people want to be able to rapidly switch between versions,
they can always use from-import or import-as.
</F>
More information about the Python-Dev
mailing list