Python 3注释 - 返回类实例的方法

时间:2017-10-13 13:23:26

标签: python python-3.x annotations type-hinting

我最近开始使用注释。我有一个单例实例,因此我有一个get_instance方法,其返回值与方法所属的类相同。

class Singleton(object):
    def __init__(self):
        pass
    def get_instance(self) -> Singleton:  # Obviously the interpreter complains about undefined name
        pass

注释get_instance方法的正确方法是什么?

0 个答案:

没有答案
相关问题