Tom*_*Tom 1 python methods overwrite prefect
我有一个类和一个子类,并且想从框架prefect.io继承一个带有装饰器@task的方法。
\n代码示例:
\n班级
\n@task\ndef test1(self):\n     pass\n子类
\ndef test2(self):\n     print("succeed")\n但现在方法test2不再具有装饰器@task了。我可以\xc2\xb4t在子类中声明@task 。我是否可以覆盖该方法但保留@task?
\n我通常会推荐类似的东西
class Base:
    @task
    def test1(self):
        return self.test1_impl()
    def test1_impl(self):
        ...
class Child:
    def test1_impl(self):
        ...
NowChild的工作不是重写修饰函数,而是重写继承的修饰函数使用的未修饰函数。