A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2012-February/116575.html below:

[Python-Dev] folding cElementTree behind ElementTree in 3.3

[Python-Dev] folding cElementTree behind ElementTree in 3.3 [Python-Dev] folding cElementTree behind ElementTree in 3.3Tim Delaney timothy.c.delaney at gmail.com
Thu Feb 16 19:44:22 CET 2012
On 17 February 2012 04:55, Antoine Pitrou <solipsis at pitrou.net> wrote:

> But then you're going from a cumbersome situation (where you have to
> import cElementTree and then fallback on regular ElementTree) to an
> even more cumbersome one (where you have to first check the Python
> version, then conditionally import cElementTree, then fallback on
> regular ElementTree).


Well, you can reverse the import so you're not relying on version numbers:

import  xml.etree.ElementTree as ElementTree

try:
    import xml.etree.cElementTree as ElementTree
except ImportError:
    pass

There is a slight cost compared to previously (always importing the python
version) and you'll still be using cElementTree directly until it's
removed, but if/when it is removed you won't notice it.

Tim Delaney
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20120217/52cb007c/attachment.html>
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4