I am a very newbie in Python I have the following code:
from SOAPpy import WSDL
fichier_wsdl = 'http://geocoder.us/dist/eg/clients/GeoCoder.wsdl'
wsdl = WSDL.Proxy(fichier_wsdl)
callInfo = wsdl.methods['geocode']
ss = wsdl.geocode('1600 Pennsylvania Ave, Washington, DC.')
print(ss)
The result is:
IMPORT: http://schemas.xmlsoap.org/soap/encoding/
no schemaLocation attribute in import
<<class 'SOAPpy.Types.typedArrayType'> results at 21824752>: [<SOAPpy.Types.structType item at 21818984>: {'city': 'Washington', 'prefix': '', 'suffix': 'NW', 'zip': 20502, 'number': 1600, 'long': -77.037684, 'state': 'DC', 'street': 'Pennsylvania', 'lat': 38.898748, 'type': 'Ave'}]
and I try to understand what type has my ss variable (the print(type(ss)) get SOAPpy.Types.typedArrayType which is not very clear for me)?
And how to have a simple variable, for the city or the street?
Let’s reformat that output for readability:
It’s telling you what type your variable is:
SOAPpy.Types.typedArrayType… try reading the SOAPpy docs to understand that (I’m a SOAPpy non-user, not even a newbie).What you really want to know is how to use that result. Looks to me like if you do
answer_dict = ss[0], you can access the fields like this:print answer_dict['city']should produceWashingtonetcso you can do
Note that
sswith the fancy type looks like it acts like a list … if your query has multiple answers (checklen(ss)), you will need to iterate over the list: