0

I have a soap function in which I need to use the argument 'pass'. "Pass" in Python is a statement so it can't be used.

How can I bypass this? I'm using Zeep for Soap.

relatie=4841
email="email"
password="password"
exportData=3600
administration={'admCode': 'BBOY', 'admMap': None}
formaat=1

result = client.service.Export(relatie=relatie, email=email, pass=password, exportData=exportData, administration=administration, formaat=format)

1 Answers1

1

There's this thing called unpacking explicit dictionaries. It basically means you can unpack a dictionary while sending it to a function and every key will act as a parameter and the value of that dictionary item will become the value for said parameter.

relatie=4841
email="email"
password="password"
exportData=3600
administration={'admCode': 'BBOY', 'admMap': None}
formaat=1

result = client.service.Export(relatie=relatie, email=email,  exportData=exportData, administration=administration, formaat=format, **{"pass" : password})

This should give the function what it wants. To learn more about this, here is a great answer explaining it with some examples.

Exploring this further, a cleaner way would be to not mix the two techniques, but instead use the unpacking of a dictionary all together on this call.

parameters = {'relatie' : 4841,
              'email' : 'email',
              'exportData' : 3600,
              'administration' : {'admCode': 'BBOY', 'admMap': None},
              'formaat' : 1, # Not sure if format is misspelled
              "pass" : "password"}

result = client.service.Export(**parameters)

This way, you don't need to create individual variables for all your options, and then add them to the dictionary/pass it individually. But the dictionary itself can act as a placeholder for all your values, and then you just unpack/expload it into the Export() function and assuming nothing is misspelled or not expected, this should do the trick.

Torxed
  • 22,866
  • 14
  • 82
  • 131