我已经看到 Evans CLI 可用于从客户端设置确定服务器上公开的消息和会话。是否可以在客户端设置上生成服务器使用的 .proto 文件(包含消息和会话详细信息)?如果是,如何访问;如果否,埃文斯如何访问这些消息?
我对 gRPC 的概念很陌生,所以这会非常有帮助。我唯一知道的是,在 GoLang 中,我们使用反射器来使 Evans CLI 能够访问消息和服务。
我试图覆盖__str__和__repr__类,如下面的代码所示。每当我调用 instance_method 时都会调用新方法,但对 class_method 的对象调用保持不变(请参阅下面的代码片段和输出,以便于了解)。有没有办法可以覆盖__str__and __repr__for@classmethod以便cls可以更改的值?
我也尝试添加__str__和__repr__as@classmethod但没有任何改变。
class Abc:
def __init__(self, name):
self.name = name
def __str__(self):
return f"Added {self.name}"
def __repr__(self):
return f"instance method repr"
def instance_method(self):
print(f"instance method {self}")
@classmethod
def __repr__(cls):
return f"class method"
@classmethod
def __str__(cls):
return f"class method"
@classmethod
def class_method(cls):
print(f"class method '{cls}'")
@staticmethod
def static_method():
print(f"static method")
def add(self, a: int,b: int,c: int) -> int:
return …Run Code Online (Sandbox Code Playgroud)