python-3.xlxmlpylintiterparse

lxml.iterparse: Unused variable 'event' (unused-variable)


It was used lxml.iterparse and the code was checked with Pylint. I want to write the code without unused variable "event". How can I do this?

context = etree.iterparse(StringIO(xml))
for event, elem in context:
    print(elem.tag)

Solution

  • resolved by using _ for throwaway variables (thanks mzjn).

    context = etree.iterparse(StringIO(xml))
    for _, elem in context:
        print(elem.tag)