I have list of elements that I need to apply and store into a variable. For some reason it not accepting elements from list?
import glob
import xmltodict
import lxml.etree as etree
xml_files = glob.glob('dir/*.xml')
list_of_xml = []
for l in [etree.parse(x) for x in xml_files]:
list_of_xml.append(l)
print(list_of_xml)
# printOutput
[<lxml.etree._ElementTree at 0x17406866b88>,
<lxml.etree._ElementTree at 0x17406795cc8>,
<lxml.etree._ElementTree at 0x174068ed7c8>]
for e in list_of_xml():
store_into_a_variable = xmltodict.parse(etree.tostring(e))
# error: TypeError: 'list' object is not callable
Why am I getting this error? I have used this for loop kind of function/notation many times to get a certain output.