I'm newbie in Python and getting the error
ET.find() takes exactly 2 arguments (3 given)
during the execution of
import xml.etree.ElementTree as ET
ns = {'conv_svc': 'http://schemas.com/serviceconvert'}
jobTypesXml = self.__server_request(url, None)
root = ET.fromstring(jobTypesXml)
for job in root.find('conv_svc:GetJobTypesResult', ns):
My first question is: what type is deduced in the following initialization?
ns = {'conv_svc': 'http://schemas.com/serviceconvert'}
Answering this I can go further to find out the error by myself! Thanks in advance!
The
find()
method only takes a single argument so you cannot do whatever it is you're attempting (at least not withfind()
).To answer your question,
{'conv_svc': 'http://schemas.com/serviceconvert'}
is a dictionary and would be interpreted as a single argument. If you are wondering about why the error states that you're passing 3 arguments (which you're not), it's becauseself
is also counted as an argument to class methods.Gives:
EDIT
Thanks to @ShreyashSSarnayak for pointing out that
find()
can take an optional extra argument in Python 3. The error message confirms that you are using Python 2, but perhaps reading some documentation associated with Python 3.