boolean is_ready - pythonic方式

时间:2014-02-02 10:49:45

标签: python

我需要检查对象是否准备就绪。我看到两个选择:

class Foo:
  def is_ready(self):
    # ...
    return result_of_some_calculations

# usage
foo.is_ready()

class Foo:
  @property
  def is_ready(self):
    return result_of_some_calculations

# usage
foo.is_ready

是否有任何pythonic偏好一个或另一个约定?

1 个答案:

答案 0 :(得分:-1)

使用装饰器比普通函数调用更具pythonic

相关问题