2020-03-14-非常牛的写法,python的property应用

class Test(object):
    crawlers = property(
        lambda self: self.tt,
        doc="Set of :class:`crawlers ` started by "
            ":meth:`crawl` and managed by this class."
    )

    def __init__(self):
        self.tt = set()

    def runt(self):
        self.crawlers.add("11")


if __name__ == "__main__":
    t = Test()
    t.runt()
    print(t.crawlers)

你可能感兴趣的:(2020-03-14-非常牛的写法,python的property应用)