首页 > 解决方案 > google fire 自动运行@property

问题描述

我使用google fire进行 cli,并在下面遇到了一个问题。

# test.py
import fire

class C:
    @property
    def foo(self):
        print('foo')

    def bar(self):
        print('bar')

fire.Fire()

然后运行为

python test.py C bar

foo
bar

看到它打印出不需要的“foo”,有什么优雅的方法可以解决这个问题吗?

标签: pythonpython-fire

解决方案


我已经通过将fire版本更新到 3.x解决了这个问题。


推荐阅读