我正在使用 python 库,我需要覆盖其中一个函数。让我们称之为module.py:
def dump(nodes, args = 'bleh' ):
...validation checks
for node in nodes:
print(node, someother_args)
def print_node(node, someother_args):
...prints in some way i don't want
Run Code Online (Sandbox Code Playgroud)
现在,我正在使用这种dump方法,我想print_node用我自己的print_node方法覆盖该函数,因为我想以不同的方式打印它。最好的方法是什么?
如何允许用户在 swagger 中输入客户端 ID 和客户端密码?这是我的安全定义,但它提示通过 client_id 和客户端机密获得的访问令牌,但我无法让它询问客户端 ID 和客户端机密?
securityDefinitions:
api_auth :
type: oauth2
authorizationUrl: 'https://randomapi/aa/token.oauth2'
flow: implicit
scopes:
Run Code Online (Sandbox Code Playgroud) class MyClass(object):
def __init__(self, name):
self.name = name
self._prof = None
self._ischanged = False
@property
def prof(self):
if not self._prof:
self._prof = "Sample Prof"
return self._prof
@prof.setter
def prof(self, value, anothervalue):
pass
Run Code Online (Sandbox Code Playgroud)
在这里您可以使用以下方法获得教授:
myclass = MyClass("sam")
myclass.prof
Run Code Online (Sandbox Code Playgroud)
但我找不到设置 prof 值的方法。
在上面的代码中,我如何将两个值传递给教授?