小编shr*_*are的帖子

任何客户端都可以从服务器生成 .proto 文件吗?

我已经看到 Evans CLI 可用于从客户端设置确定服务器上公开的消息和会话。是否可以在客户端设置上生成服务器使用的 .proto 文件(包含消息和会话详细信息)?如果是,如何访问;如果否,埃文斯如何访问这些消息?

我对 gRPC 的概念很陌生,所以这会非常有帮助。我唯一知道的是,在 GoLang 中,我们使用反射器来使 Evans CLI 能够访问消息和服务。

protocol-buffers proto grpc

5
推荐指数
1
解决办法
1694
查看次数

在python中覆盖@classmethods的__str__方法

我试图覆盖__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)

python oop methods class class-method

4
推荐指数
1
解决办法
2278
查看次数

标签 统计

class ×1

class-method ×1

grpc ×1

methods ×1

oop ×1

proto ×1

protocol-buffers ×1

python ×1