MCPcopy Index your code
hub / github.com/RustPython/RustPython / remove

Method remove

Lib/xml/etree/ElementTree.py:257–274  ·  view source on GitHub ↗

Remove matching subelement. Unlike the find methods, this method compares elements based on identity, NOT ON tag value or contents. To remove subelements by other means, the easiest way is to use a list comprehension to select what elements to keep, and then use sli

(self, subelement)

Source from the content-addressed store, hash-verified

255 raise TypeError('expected an Element, not %s' % type(e).__name__)
256
257 def remove(self, subelement):
258 """Remove matching subelement.
259
260 Unlike the find methods, this method compares elements based on
261 identity, NOT ON tag value or contents. To remove subelements by
262 other means, the easiest way is to use a list comprehension to
263 select what elements to keep, and then use slice assignment to update
264 the parent element.
265
266 ValueError is raised if a matching element could not be found.
267
268 """
269 # assert iselement(element)
270 try:
271 self._children.remove(subelement)
272 except ValueError:
273 # to align the error message with the C implementation
274 raise ValueError("Element.remove(x): element not found") from None
275
276 def find(self, path, namespaces=None):
277 """Find first matching element by tag name or path.

Callers 4

test_simpleopsMethod · 0.95
removeChildMethod · 0.45
removeChildMethod · 0.45
_includeFunction · 0.45

Calls

no outgoing calls

Tested by 1

test_simpleopsMethod · 0.76