SOAPpy - reserved word in the list of named parameters

I use SOAPpy to access the SOAP Webservice. This call to the findPathwaysByText function works just fine:

server.findPathwaysByText (query= 'WP619', species = 'Mus musculus') 

However, this login function call is not executed:

 server.login (user='amarillion', pass='*****') 

Since pass is a reserved word, python will not run this. Is there a workaround?

+3
source share
2 answers

You can try:

 d = {'user':'amarillion', 'pass':'*****' } server.login(**d) 

This is conveyed in this dictionary as if they were key arguments (**)

+5
source

you can say

 server.login(user='amarillion', **{'pass': '*****'}) 

The double-asterix syntax uses keyword arguments. Here is a simple example that shows what happens:

 def f(a, b): return a + b kwargs = {"a": 5, "b": 6} return f(**kwargs) # same as saying f(a=5, b=6) 
+1
source

Source: https://habr.com/ru/post/1392186/


All Articles