On 4/7/06, Greg Ewing <[EMAIL PROTECTED]> 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 < [EMAIL PROTECTED]>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to