[Python-Dev] elementtree in stdlib
Thomas Wouters
thomas at python.org
Fri Apr 7 10:54:39 CEST 2006
On 4/7/06, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
>
> Trent Mick wrote:
>
> > try:
> > import xml.etree.ElementTree as ET # in python >=2.5
> > except ImportError:
> > ... etc ad nauseam
>
> For situations like this I've thought it might
> be handy to be able to say
>
> import xml.etree.ElementTree or cElementTree or \
> elementtree.ElementTree or lxml.etree as ET
That does look cute (note that you can use parentheses rather than
newline-escaping to continue the line.) I assume it should come with:
from (xml.etree.cElementTree or xml.etree.ElementTree or
elementtree.cElementTree or elementtree.ElementTree or
lxml.etree) import ElementTree as ET
(Parentheses there are currently illegal.)
But should it also come with:
from xml.etree import (cElementTree or ElementTree) as ElementTree
and combined:
from xml.etree or elementtree import cElementTree or ElementTree as
ElementTree
and of course combined with explicit-relative imports:
from .custometree or xml.etree or elementtree import cElementTree or
ElementTree as ET
or is that all going too far? :)
--
Thomas Wouters <thomas at python.org>
Hi! I'm a .signature virus! copy me into your .signature file to help me
spread!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20060407/6b293939/attachment.html
More information about the Python-Dev
mailing list