Hi all
I noticed a behaviour in lxml that surprised me, so I thought I would
mention it.
Versions - python 3.3.2, lxml 3.2.1.
Consider the following - standard python slicing -
>>> a = [1, 2, 3, 4]
>>> b = [5, 6, 7, 8]
>>> a[:0] = b[0:]
>>> a
[5, 6, 7, 8, 1, 2, 3, 4]
>>> b
[5, 6, 7, 8]
This is what I expected.
Then look at this - lxml slicing -
>>> from lxml import etree
>>> a = etree.fromstring('<a1><a1.1/><a1.2/></a1>')
>>> b = etree.fromstring('<b1><b1.1/><b1.2/></b1>')
>>> a[:0] = b[0:]
>>> etree.tostring(a)
b'<a1><b1.1/><b1.2/><a1.1/><a1.2/></a1>'
>>> etree.tostring(b)
b'<b1/>'
>>>
The slicing worked, but it removed the contents of b.
Is this intentional?
Frank Millman