Re: list-like behaviour of etree.Element

2007-03-05 Thread Fredrik Lundh
Raymond Hettinger wrote:

 On Mar 4, 12:48 pm, Daniel Nogradi [EMAIL PROTECTED] wrote:

 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 



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: list-like behaviour of etree.Element

2007-03-05 Thread Daniel Nogradi
  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.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: list-like behaviour of etree.Element

2007-03-05 Thread John Machin
On Mar 5, 8:00 pm, Fredrik Lundh [EMAIL PROTECTED] wrote:


 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

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: list-like behaviour of etree.Element

2007-03-05 Thread [EMAIL PROTECTED]
On Mar 5, 1:00 am, Fredrik Lundh [EMAIL PROTECTED] wrote:
 Raymond Hettinger wrote:
  On Mar 4, 12:48 pm, Daniel Nogradi [EMAIL PROTECTED] wrote:
  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

-- 
http://mail.python.org/mailman/listinfo/python-list


list-like behaviour of etree.Element

2007-03-04 Thread Daniel Nogradi
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)?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: list-like behaviour of etree.Element

2007-03-04 Thread Terry Reedy

Daniel Nogradi [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
| 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)?

I think you should turn the question around: why should such be added?
I imagine that the author wrote the methods he and his users thought 
necessary.
Anything more has various costs.

tjr



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: list-like behaviour of etree.Element

2007-03-04 Thread Raymond Hettinger
On Mar 4, 12:48 pm, Daniel Nogradi [EMAIL PROTECTED] wrote:
 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

-- 
http://mail.python.org/mailman/listinfo/python-list