在同一类中调用函数/方法时,类方法是否合适?

时间:2020-06-09 15:25:21

标签: python python-3.x

在同一类中调用函数/方法时,类方法是否合适?不知道我是否使用这种方法违反了规则或惯例。示例:

class Tools:

    @classmethod
    def method_one(cls, foo, bar):
        number = foo + bar
        msg = cls.method_two(number)
        print(msg)

    @staticmethod
    def method_two(num_num):
        return f'{num_num} is the magic number'

0 个答案:

没有答案