473,385 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

ElementTree - Why not part of the core?

Why is the ElementTree API not a part of the Python core?
I've recently been developing a script for accessing the Miva API only
to find all the core API's provided by Python for parsing XML is messy
and complicated. Many of the examples I see for parsing the data using
these API's uses a similar additional Class for collapsing the XML data
into a more manageable format.
This is clearly not following the Python-way of clean, simple code and
easy development.

ElementTree on the other hand provides incredibly easy access to XML
elements and works in a more Pythonic way. Why has the API not been
included in the Python core?

Dec 7 '05 #1
28 1625
Doug,

I agree with you, ElementTree is fast & pythonic.
Certainly does make sense to me.

Dec 7 '05 #2
do**********@gmail.com wrote:
ElementTree on the other hand provides incredibly easy access to XML
elements and works in a more Pythonic way. Why has the API not been
included in the Python core?


While I fully agree that ElementTree is far more Pythonic than the
dom-based stuff in the core, this issue has been discussed on
python-dev[1]. Fredrik Lundh's response:

shipping stable versions of ElementTree/cElementTree (or PIL, or
python-doc, or exemaker, or what else you might find useful) with
official Python releases is perfectly okay.

moving the main trunk and main development over to the Python CVS is
another thing, entirely.

I think some people were hoping that instead of adding these things to
the standard library, we would come up with a better package manager
that would make adding these things to your local library much simpler.

STeVe

[1]http://www.python.org/dev/summary/2005-06-01_2005-06-15.html#reorganising-the-standard-library-again
Dec 7 '05 #3
Steven Bethard napisał(a):
ElementTree on the other hand provides incredibly easy access to XML
elements and works in a more Pythonic way. Why has the API not been
included in the Python core?


While I fully agree that ElementTree is far more Pythonic than the
dom-based stuff in the core, this issue has been discussed on
python-dev[1]. Fredrik Lundh's response:

shipping stable versions of ElementTree/cElementTree (or PIL, or
python-doc, or exemaker, or what else you might find useful) with
official Python releases is perfectly okay.

moving the main trunk and main development over to the Python CVS is
another thing, entirely.

I think some people were hoping that instead of adding these things to
the standard library, we would come up with a better package manager
that would make adding these things to your local library much simpler.


What about more intelligent installer, that after installing core
packages, would present user a list of recommended packages in few
groups (like "markup processing", "popular RDBMS interaction", "web
frameworks", "multimedia", etc.) and would be able to fetch and install
packages using PyPI descriptions? Unattended install with this feature
would be great.

--
Jarek Zgoda
http://jpa.berlios.de/
Dec 7 '05 #4
Steven Bethard wrote:
ElementTree on the other hand provides incredibly easy access to XML
elements and works in a more Pythonic way. Why has the API not been
included in the Python core?


While I fully agree that ElementTree is far more Pythonic than the
dom-based stuff in the core, this issue has been discussed on
python-dev[1]. Fredrik Lundh's response:

shipping stable versions of ElementTree/cElementTree (or PIL, or
python-doc, or exemaker, or what else you might find useful) with
official Python releases is perfectly okay.

moving the main trunk and main development over to the Python CVS is
another thing, entirely.

I think some people were hoping that instead of adding these things to
the standard library, we would come up with a better package manager
that would make adding these things to your local library much simpler.


I still hope that the standard distribution will, in a not too distant future,
bundle more external libraries. as things are today, "including something
in the core" means that you have to transfer code and rights to the PSF.

as I've said many times, if the Linux folks can build distributions that con-
sists of thousands of individually maintained pieces, the Python distributors
should be able to handle a few dozen components.

</F>

Dec 7 '05 #5
Before that can happen we'll need some better management of co-existing
different versions of a package. You'll want to be able to use newer
versions of external packages without breakage in the standard library.

Dec 7 '05 #6

Steven Bethard wrote:
--snip--
I think some people were hoping that instead of adding these things to
the standard library, we would come up with a better package manager
that would make adding these things to your local library much simpler.

STeVe

[1]http://www.python.org/dev/summary/2005-06-01_2005-06-15.html#reorganising-the-standard-library-again


A better package manager would be great but does not
replace having things in the core. Distributed code that
relies on external packages puts a significantly greater
burden on the user of the code. I suppose there are
ways to get around it but often it means at a minimum
the user will need to read the install instructions (which
seems to be asking a lot for some people.) And at some
companies, one has to jump though beauracratic hoops
for each external package installed. And I personally
stear away from packages that have a long list of
prerequisites.

With things I've written that I thought might be used
by others, I've gone to some lengths to use only modules
in the standard library.

Dec 7 '05 #7
"Fredrik Lundh" <fr*****@pythonware.com> writes:
as I've said many times, if the Linux folks can build distributions that con-
sists of thousands of individually maintained pieces, the Python distributors
should be able to handle a few dozen components.


Yes, but "distributers" is not necessarily "maintainers". How many
components are there in the Activestate Python distribution?
Enthoughts? Others?

The maintainers of Linux/gcc/etc. don't worry about creating a
distribution that includes lots of third party software. Why should
the maintainers of Python be any different?

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Dec 7 '05 #8
<ru***@yahoo.com> wrote:
...
seems to be asking a lot for some people.) And at some
companies, one has to jump though beauracratic hoops
for each external package installed. And I personally
stear away from packages that have a long list of
prerequisites.


Funny -- me, I prefer to steer away from companies with lots of
bureaucracy, instead!-)
Alex
Dec 8 '05 #9
do**********@gmail.com wrote:
ElementTree on the other hand provides incredibly easy access to XML
elements and works in a more Pythonic way. Why has the API not been
included in the Python core?


I'd really like to see that too. Sure, it's fairly trivial to install
it, but each different package that needs to be installed from another
source, built and tested on multiple platforms etc, means more work.
For complex software systems, these kinds of configuration issues
take a lot of efforts.

We're deploying our software on a number of different platforms. We
certainly depend on Python, so a standard Python install will always
be included. Using standard library modules is for free. Using yet
another third party library has a cost, even if some Cheese Shop or
whatever might make the cost slightly lower.

We have very friendly configuration management guys here, so if I
insisted, I'm sure they'd let me have elementTree included, but I
hesitate to ask for it. It does add a burden on CM, increases the
risk that a deployment will fail, and from a code maintenance point
of view, it's a double edged sword: On one hand, it's a much better
API, but on the other hand, it's not documented in the standard
Python docs or in the Nutshell book, and a new developer would need
to figure out what this foreign beast was, and where to find docs.
(Alternatively, I'd have to (God forbid) document my actions. ;)
Dec 8 '05 #10
Magnus Lycka wrote:
We're deploying our software on a number of different platforms. We
certainly depend on Python, so a standard Python install will always
be included. Using standard library modules is for free. Using yet
another third party library has a cost, even if some Cheese Shop or
whatever might make the cost slightly lower.

We have very friendly configuration management guys here, so if I
insisted, I'm sure they'd let me have elementTree included, but I
hesitate to ask for it. It does add a burden on CM, increases the
risk that a deployment will fail, and from a code maintenance point
of view, it's a double edged sword: On one hand, it's a much better
API, but on the other hand, it's not documented in the standard
Python docs or in the Nutshell book, and a new developer would need
to figure out what this foreign beast was, and where to find docs.
(Alternatively, I'd have to (God forbid) document my actions. ;)


on the other hand, you can bundle ElementTree with your applications simply
by including the ElementTree.py and (optionally) the ElementPath.py modules.

(you are allowed to add new Python modules to the project, I hope ;-)

(and yes, HTML documentation is included in the source distribution kit)
but seriously, given how easy it is to build things with distutils, I don't think your
configuration folks would have much trouble adding support for "anything that has
a setup file, and is reasonably self-contained" to their build scripts.

we usually use one large shell script with a bunch of "cd source; run setup install"
sections in it, e.g.

cd $PREFIX
cd src/griblib-2.1.1-20051125
$PYTHON setup.py install --prefix=$PREFIX

plus a Python script that does a sanity check at the end to make sure that the build
script actually managed to build and install everything we need. running the regression
test suite on the build is a good way to weed out build problems too; just make sure
you redirect the build output to a file, so you can check the logs afterwards.

all source kits are checked into the version management system, of course. no tarballs
are involved in the build process. just check things out and run the script, wait a couple
of minutes, and you're done.

</F>

Dec 8 '05 #11

Fredrik Lundh wrote:
Steven Bethard wrote:
ElementTree on the other hand provides incredibly easy access to XML
elements and works in a more Pythonic way. Why has the API not been
included in the Python core?
While I fully agree that ElementTree is far more Pythonic than the
dom-based stuff in the core, this issue has been discussed on
python-dev[1]. Fredrik Lundh's response:

shipping stable versions of ElementTree/cElementTree (or PIL, or
python-doc, or exemaker, or what else you might find useful) with
official Python releases is perfectly okay.

moving the main trunk and main development over to the Python CVS is
another thing, entirely.

I think some people were hoping that instead of adding these things to
the standard library, we would come up with a better package manager
that would make adding these things to your local library much simpler.


I still hope that the standard distribution will, in a not too distant future,
bundle more external libraries. as things are today, "including something
in the core" means that you have to transfer code and rights to the PSF.

as I've said many times, if the Linux folks can build distributions that con-
sists of thousands of individually maintained pieces, the Python distributors
should be able to handle a few dozen components.


I'd like to add my vote in favour of this.

There are a few popular extensions that most users would like easy
access to. PIL and ElementTree both fall into this category.

Thanks

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml
</F>


Dec 8 '05 #12
ru***@yahoo.com wrote:
I think some people were hoping that instead of adding these things
to
the standard library, we would come up with a better package manager
that would make adding these things to your local library much
simpler.

STeVe
[1]http://www.python.org/dev/summary/2005-06-01_2005-06-15.html#reorganising-th
e-standard-library-again
A better package manager would be great but does not
replace having things in the core. Distributed code that
relies on external packages puts a significantly greater
burden on the user of the code.


Seconded.

One thing I really fear about the otherwise great EasyInstall (and Python Eggs)
is that we could forget about
Let's not turn the Python standard library into the CPAN mess, where there are
5 different libraries for adding two numbers, so that it's then impossible to
grab a random perl program and read it, without going through 150 different man
pages you never saw before. I don't need 450 libraries to compute MD5, or to
zip a file, or 140 different implementations of random numbers. There will
always be external libraries for specific purposes, but I'd rather the standard
library to stay focused on provided a possibly restricted set of common
features with a decent interface/implementation.

This said, I'd also like to see ElementTree in the standard library. We already
have a SAX and a DOM, but we need a Pythonic XML library, and ElementTree is
just perfect.
--
Giovanni Bajo
Dec 8 '05 #13
Giovanni Bajo wrote:
One thing I really fear about the otherwise great EasyInstall (and
Python Eggs) is that we could forget about...


.... how important is to have a standard library. The fact that it's easy to
install external modules shouldn't make us drop the standard library. A
standard library means a great uniformity across programs. Whenever I open a
Python program which uses ZipFile, or socket, or re, I can read it
*immediately*. If it uses an external library / framework, I have to go study
its manual and documentation. Proliferation of external libraries is good, but
people should normally use the standard library modules for uniformity.

In other words, I disagree with this message:
http://mail.python.org/pipermail/pyt...ne/054102.html

My personal hope is that Python 3.0 will have a nice cleaned-up standard
library with even more features than Python 2.x. As I said the in other
message, let's not end up into the CPAN mess just because it's now technically
easier!
--
Giovanni Bajo
Dec 8 '05 #14
Fredrik Lundh wrote:
but seriously, given how easy it is to build things with distutils, I don't think your
configuration folks would have much trouble adding support for "anything that has
a setup file, and is reasonably self-contained" to their build scripts.


True. It's one more thing to keep track of though. It's a separate
configuration item. We need to keep track of which version to use,
and it needs to get built, installed and validated on all supported
platforms.

I already include Twisted (and thus ZopeInterface) like that. We
sometimes need high speed in XML parsing, so I'd like to use
cElementTree, but just like the two other packages, I assume that
it's unproblematic to build the included C code. So, you're right,
it's not much trouble, just two more pebbles (cElementTree and
ElementTree) on a fairly heavy load, where stuff like Oracle and MQ
Series are more like boulders.

Right now, I would like to improve the performace of a program that
does a lot of XML parsing. I haven't profiled that yet, so I don't
know if XML parsing is the bottle neck, but if I can improve perfor-
mance significantly with cElementTree, I'll certainly push for that.
/Magnus
Dec 8 '05 #15
ElementTree on the other hand provides incredibly easy access to XML
elements and works in a more Pythonic way. Why has the API not been
included in the Python core?


Magnus> I'd really like to see that too. Sure, it's fairly trivial to
Magnus> install it, but each different package that needs to be
Magnus> installed from another source, built and tested on multiple
Magnus> platforms etc, means more work.

More work than reimplementing the functionality or living with a miserable
API (I'm thinking normal DOM APIs)?

Skip
Dec 8 '05 #16
ElementTree on the other hand provides incredibly easy access to XML
elements and works in a more Pythonic way. Why has the API not been
included in the Python core?


I think the key here is ElementTree's Pythoninc API. While it's clearly
possible to install it as a third-party package, I think there's a clear
best-of-breed aspect here that suggests it belongs in the standard
distribution simply to discourage continued use of DOM-based APIs.

Skip
Dec 8 '05 #17
> I still hope that the standard distribution will, in a not too distant future,
bundle more external libraries. as things are today, "including something
in the core" means that you have to transfer code and rights to the PSF.


Your description of how to include something in the core isn't entirely
accurate. If you visit http://www.python.org/psf/contrib.html, you'll
see that you don't need to transfer your rights to the PSF. Rather,
you need to sign an agreement giving the PSF the rights to relicense
the code. The PSF currently require that the original submission be
licensed under one of two open source licenses. Personally, I can
imagine accepting a wider range of initial licenses in the future.

As for transferring the code, there needs to be a copy in the Python
source control system, sure. There's some unavoidable complexity
involved in managing a software distribution composed of third party
software packages. At the very least, you've got the original sources
and the copy in the distribution package, which leads to a
synchronization problem.

Jeremy

Dec 8 '05 #18
sk**@pobox.com wrote:
I think the key here is ElementTree's Pythoninc API. While it's clearly
possible to install it as a third-party package, I think there's a clear
best-of-breed aspect here that suggests it belongs in the standard
distribution simply to discourage continued use of DOM-based APIs.


I second this. Guido has said many times that the stdlib is for
best-of-breed modules that have proven themselves in the wild.
ElementTree has proven itself in the wild and is clearly best-of-breed.
And dramatically better (IMHO) than the APIs currently included in the
stdlib[1].

I don't have a whole lot of free time, and I'm not sure exactly how I
could help, but if there's anything I could do that would help get
ElementTree into the stdlib, let me know.

STeVe

[1] If I had my way, we'd deprecate and then remove the current Python
xml modules. But of course then people would complain that Python
doesn't have a SAX or DOM API. Of course we could tell them that they
don't need it and that ElementTree is easier, but I'm not sure people
really want to fight that battle.
Dec 8 '05 #19
sk**@pobox.com wrote:
>> ElementTree on the other hand provides incredibly easy access to XML
>> elements and works in a more Pythonic way. Why has the API not been
>> included in the Python core?


Magnus> I'd really like to see that too. Sure, it's fairly trivial to
Magnus> install it, but each different package that needs to be
Magnus> installed from another source, built and tested on multiple
Magnus> platforms etc, means more work.

More work than reimplementing the functionality or living with a miserable
API (I'm thinking normal DOM APIs)?


More work for the CM people. Less work for me.
Dec 9 '05 #20
do**********@gmail.com wrote:
ElementTree on the other hand provides incredibly easy access to XML
elements and works in a more Pythonic way. Why has the API not been
included in the Python core?


$ svn up
$ make
....
$ python
Python 2.5a0 (#1, Dec 12 2005, 19:26:49)
import xml.etree.ElementTree as ET
root = ET.XML("<message>hello, world!</message>")
root <Element text at 402f73ac> root.text

'hello, world!'

http://svn.python.org/view/python/trunk/Lib/xml/etree/

(and it's all your fault ;-)

</F>

Dec 13 '05 #21
gregory@home:~$ python
Python 2.5a0 (#1, Dec 14 2005, 14:11:55)
[GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import xml.etree.ElementTree as ET Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.5/xml.py", line 20, in <module>
import xmlcore
ImportError: No module named xmlcore


Dec 14 '05 #22
This I've got after

make install

and

me@home:~$ python

When launching ./python from ./trunk, everything is OK. Is it a problem
with me or with installation?

Dec 14 '05 #23
> $ python
Python 2.5a0 (#1, Dec 12 2005, 19:26:49)
import xml.etree.ElementTree as ET

hip hip hurray!
http://svn.python.org/view/python/trunk/Lib/xml/etree/


don't know how this works, the link now seems to be:

http://svn.python.org/view/python/tr...xmlcore/etree/

Dec 14 '05 #24
Istvan Albert wrote:
$ python
Python 2.5a0 (#1, Dec 12 2005, 19:26:49)
import xml.etree.ElementTree as ET

hip hip hurray!

http://svn.python.org/view/python/trunk/Lib/xml/etree/

don't know how this works, the link now seems to be:

http://svn.python.org/view/python/tr...xmlcore/etree/

For 2.5 the current xml namespaces will, I believe, move to xmlcore.

Compatibility code will replace the current xml package, to ensure that
core modules not replaced by other components will still be available
under their old names. This will allow better handling of fallbacks
when, say, an optional C extension module is absent and it can be
replaced by an xmlcore pure Python module.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Dec 14 '05 #25
Istvan Albert wrote:
don't know how this works, the link now seems to be:

http://svn.python.org/view/python/tr...xmlcore/etree/


people are moving things around, but xml.etree.ElementTree should still
work when they're done.

("xml" dispatches to either xmlcore or _xmlplus, depending on what you
have installed. "xmlcore" always gives you the bundled stuff.)

</F>

Dec 14 '05 #26
Gregory Petrosyan wrote:
This I've got after

make install

and

me@home:~$ python

When launching ./python from ./trunk, everything is OK. Is it a problem
with me or with installation?


things are being moved around, and installation seems to be broken at the
moment (it doesn't install the Lib/xmlcore tree)

</F>

Dec 14 '05 #27
> > When launching ./python from ./trunk, everything is OK. Is it a problem
with me or with installation?


things are being moved around, and installation seems to be broken at the
moment (it doesn't install the Lib/xmlcore tree)


if you have time, can you update and try again ?

(let me know if it's still broken on your machine)

</F>

Dec 14 '05 #28
gregory@home:~$ python
Python 2.5a0 (#4, Dec 14 2005, 22:08:59)
[GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
from xml.etree import ElementTree as ET
ET <module 'xml.etree.ElementTree' from
'/usr/local/lib/python2.5/xmlcore/etree/ElementTree.pyc'>

Thanks for fix.

Dec 14 '05 #29

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Damjan | last post by:
Given the folowing XML snippet, I build an ElementTree instance with et=ElementTree.fromstring(..). Now et.text returns just '\n text\n some other text'. Is there any way I could get everything...
9
by: Chris Spencer | last post by:
Does anyone know how to make ElementTree preserve namespace prefixes in parsed xml files? The default behavior is to strip a document of all prefixes and then replace them autogenerated prefixes...
1
by: mirandacascade | last post by:
O/S: Windows 2K Vsn of Python: 2.4 Currently: 1) Folder structure: \workarea\ <- ElementTree files reside here \xml\ \dom\
15
by: Steven Bethard | last post by:
I'm having trouble using elementtree with an XML file that has some gbk-encoded text. (I can't read Chinese, so I'm taking their word for it that it's gbk-encoded.) I always have trouble with...
30
by: Chas Emerick | last post by:
I looked around for an ElementTree-specific mailing list, but found none -- my apologies if this is too broad a forum for this question. I've been using the lxml variant of the ElementTree API,...
5
by: saif.shakeel | last post by:
#!/usr/bin/env python from elementtree import ElementTree as Element tree = et.parse("testxml.xml") for t in tree.getiterator("SERVICEPARAMETER"): if t.get("Semantics") == "localId":...
0
by: sndive | last post by:
I have a weid problem. If i do this: import elementtree.ElementTree as ET .... tree = ET.parse("whatever") root = tree.getroot() r = root.find('last') print r return root where last is not an...
2
Zver
by: Zver | last post by:
Hey All! I'm developing application that uses ElementTree for XML parsing. In python 2.5 ElementTree is part of standard "libs". Now my question is. How would you detect version of python and...
11
by: Peter Pei | last post by:
One bad design about elementtree is that it has different ways parsing a string and a file, even worse they return different objects: 1) When you parse a file, you can simply call parse, which...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.