This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients eric.smith, rhettinger, rowan.bradley, scoder, tim.peters
Date 2021-03-25.17:45:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1616694304.02.0.76539643895.issue43618@roundup.psfhosted.org>
In-reply-to
Content
Interestingly, this isn't an LXML bug.  It is a documented difference from how the standard library works:

    https://lxml.de/tutorial.html#elements-are-lists

So, if you want use random.shuffle(), you need the standard library ElementTree instead of lxml.

This:

    from lxml.etree import Element

    root = Element('outer')
    root.append(Element('zero'))
    root.append(Element('one'))
    root.append(Element('two'))
    root[0] = root[1]
    print([e.tag for e in root])

Produces:

   ['one', 'two']
History
Date User Action Args
2021-03-25 17:45:04rhettingersetrecipients: + rhettinger, tim.peters, scoder, eric.smith, rowan.bradley
2021-03-25 17:45:04rhettingersetmessageid: <1616694304.02.0.76539643895.issue43618@roundup.psfhosted.org>
2021-03-25 17:45:04rhettingerlinkissue43618 messages
2021-03-25 17:45:03rhettingercreate