SOAPpy - reserved word in named parameter list

微笑、不失礼 提交于 2019-12-10 18:32:25

问题


I'm using SOAPpy to access a SOAP Webservice. This call to the function findPathwaysByText works just fine:

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

However, this call to the function login does not:

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

Because pass is a reserved word, python won't run this. Is there a workaround?


回答1:


You could try:

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

This passes in the given dictionary as though they were keyword arguments (the **)




回答2:


You can say

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

The double-asterix syntax here applies keyword arguments. Here's a simple example that shows what's happening:

def f(a, b):
    return a + b

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


来源:https://stackoverflow.com/questions/870455/soappy-reserved-word-in-named-parameter-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!