Skip to content

Commit d502d73

Browse files
Fix the description of Element.keys() and Element.items()
They do not return a list in the Python implementation, which returns dict views. And the attributes are no longer returned in an arbitrary order: the attrib dict preserves the insertion order.
1 parent f4eee16 commit d502d73

2 files changed

Lines changed: 6 additions & 12 deletions

File tree

Doc/library/xml.etree.elementtree.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -956,14 +956,12 @@ Element Objects
956956

957957
.. method:: items()
958958

959-
Returns the element attributes as a sequence of (name, value) pairs. The
960-
attributes are returned in an arbitrary order.
959+
Returns the element attributes as (name, value) pairs.
961960

962961

963962
.. method:: keys()
964963

965-
Returns the elements attribute names as a list. The names are returned
966-
in an arbitrary order.
964+
Returns the element attribute names.
967965

968966

969967
.. method:: set(key, value)

Lib/xml/etree/ElementTree.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -356,21 +356,17 @@ def set(self, key, value):
356356
self.attrib[key] = value
357357

358358
def keys(self):
359-
"""Get list of attribute names.
359+
"""Get attribute names.
360360
361-
Names are returned in an arbitrary order, just like an ordinary
362-
Python dict. Equivalent to attrib.keys()
361+
Equivalent to attrib.keys()
363362
364363
"""
365364
return self.attrib.keys()
366365

367366
def items(self):
368-
"""Get element attributes as a sequence.
367+
"""Get element attributes as (name, value) pairs.
369368
370-
The attributes are returned in arbitrary order. Equivalent to
371-
attrib.items().
372-
373-
Return a list of (name, value) tuples.
369+
Equivalent to attrib.items().
374370
375371
"""
376372
return self.attrib.items()

0 commit comments

Comments
 (0)