Python: How to pass more than one argument to the property getter?

前端 未结 7 1982
清酒与你
清酒与你 2021-01-31 06:48

Consider the following example:

class A:
    @property
    def x(self): return 5

So, of course calling the a = A(); a.x will retur

7条回答
  •  死守一世寂寞
    2021-01-31 07:41

    a property should only depend on the related object. If you want to use some external parameters, you should use methods.

提交回复
热议问题