473,387 Members | 1,678 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,387 software developers and data experts.

list-like behaviour of etree.Element

The etree.Element (or ElementTree.Element) supports a number of
list-like methods: append, insert, remove. Any special reason why it
doesn't support pop and extend (and maybe count)?
Mar 4 '07 #1
5 1450
On Mar 4, 12:48 pm, "Daniel Nogradi" <nogr...@gmail.comwrote:
The etree.Element (or ElementTree.Element) supports a number of
list-like methods: append, insert, remove. Any special reason why it
doesn't support pop and extend (and maybe count)?
Those methods would not be hard to add. Perhaps, submit a feature
request to Fredrik Lundh on SourceForge and see what he thinks there
is merit in more closely emulating the list API. Of the methods you
listed, the case is probably strongest for extend().
Raymond

Mar 5 '07 #2
Raymond Hettinger wrote:
On Mar 4, 12:48 pm, "Daniel Nogradi" <nogr...@gmail.comwrote:
>The etree.Element (or ElementTree.Element) supports a number of
list-like methods: append, insert, remove. Any special reason why it
doesn't support pop and extend (and maybe count)?

Those methods would not be hard to add. Perhaps, submit a feature
request to Fredrik Lundh on SourceForge and see what he thinks there
is merit in more closely emulating the list API. Of the methods you
listed, the case is probably strongest for extend().
extend() will be in the next release:

http://effbot.org/zone/elementtree-changes-13.htm

(lxml.etree already has it, btw).

not sure I see the point of pop() and count(). a successful feature request
would need to include some really compelling use cases.

</F>

Mar 5 '07 #3
The etree.Element (or ElementTree.Element) supports a number of
list-like methods: append, insert, remove. Any special reason why it
doesn't support pop and extend (and maybe count)?
Those methods would not be hard to add. Perhaps, submit a feature
request to Fredrik Lundh on SourceForge and see what he thinks there
is merit in more closely emulating the list API. Of the methods you
listed, the case is probably strongest for extend().

extend() will be in the next release:

http://effbot.org/zone/elementtree-changes-13.htm

(lxml.etree already has it, btw).

not sure I see the point of pop() and count(). a successful feature request
would need to include some really compelling use cases.
Great! I also first thought of extend because that would be really
useful, pop and count just came to mind because they exist for lists.
But if extend will be added that'll already make life easier,
pop/count is probably not that much needed.
Mar 5 '07 #4
On Mar 5, 8:00 pm, "Fredrik Lundh" <fred...@pythonware.comwrote:
>
extend() will be in the next release:

http://effbot.org/zone/elementtree-changes-13.htm
Hi Fredrik,
"The library requires Python 2.2 or newer." -- Does this apply to
cElementTree as well?

Reason for asking: my xlrd package works with Python 2.1 or later. I'm
using cElementTree in a so-far-so-good prototype of parsing Excel
2007 .XLSX files ...

Regards,
John
Regards,
John

Mar 5 '07 #5
On Mar 5, 1:00 am, "Fredrik Lundh" <fred...@pythonware.comwrote:
Raymond Hettinger wrote:
On Mar 4, 12:48 pm, "Daniel Nogradi" <nogr...@gmail.comwrote:
The etree.Element (or ElementTree.Element) supports a number of
list-like methods: append, insert, remove. Any special reason why it
doesn't support pop and extend (and maybe count)?
Those methods would not be hard to add. Perhaps, submit a feature
request to Fredrik Lundh on SourceForge and see what he thinks there
is merit in more closely emulating the list API. Of the methods you
listed, the case is probably strongest for extend().

extend() will be in the next release:

http://effbot.org/zone/elementtree-changes-13.htm

(lxml.etree already has it, btw).

not sure I see the point of pop() and count(). a successful feature request
would need to include some really compelling use cases.

</F>
Pop could be useful. I could use it.

I'm working on a story and submission tracker. It stores everything
in XML and I use a sax parser to build reports. If I have to update
one bit of data (say, a submission returns a sale) I have to use a
nasty extraction program that returns the submission node AND the rest
of the document (minus that node). Then I make the changes of the
individual submission, and append it to the end of submissions data
document. (I don't care about the order of items in the file, since
my reporting methods re-order everything anyway.)

Josh

Mar 5 '07 #6

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

Similar topics

5
by: Jeffrey Silverman | last post by:
Hi, all. I have a linked list. I need an algorithm to create a tree structure from that list. Basically, I want to turn this: $list = array( array( 'id' => 'A', 'parent_id' => null, 'value'...
4
by: GrelEns | last post by:
hello, i wonder if this possible to subclass a list or a tuple and add more attributes ? also does someone have a link to how well define is own iterable object ? what i was expecting was...
0
by: semarketing-request | last post by:
>>>> This is a multi-part message in MIME format. **** Command 'this' not recognized. **** No valid commands found. **** Commands must be in message BODY, not in HEADER. **** Help for...
21
by: M. Clift | last post by:
Hi All, Could someone help me out with this? items = ('a', 'b', 'c', 'd') items + 1 = ( 'b', 'c', 'd', 'a') items + 2 = ( 'c', 'd', 'a', 'b') items + 3 = ( 'd', 'a', 'b', 'c') trans = 1
23
by: Mike Meyer | last post by:
Ok, we've added list comprehensions to the language, and seen that they were good. We've added generator expressions to the language, and seen that they were good as well. I'm left a bit...
115
by: J | last post by:
I've run CSSCheck on my style sheets and I always get a warning similar to this: "font: bold 9pt/100% sans-serif Warning: Absolute length units should not generally be used on the Web ..." ...
7
by: Shawn Windle | last post by:
----begin node.h-------- #ifndef NODE_H #define NODE_H #include <iostream> //NULL using namespace std; class node {
2
by: Alexander Malkis | last post by:
//Consider: class A { /*...*/ }; template<class T> class list {/*... */ }; void f(const list<const A*> lst) { /*...doesn't change the arg...*/ } void g(list<A*> lst) { f(lst);...
5
by: Darryl B | last post by:
I can not get anywhere on this project I'm tryin to do. I'm not expecting any major help with this but any would be appreciated. The assignment is attached. The problem I'm having is trying to set...
4
by: blrmaani | last post by:
Here is what I want: string s1 = "This is a list of string"; list<string> s2 = s1.some_method(); Now, I should be able to traverse list s2 and get each member ( which is of type 'string' ). ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.