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

前端 未结 7 1972
清酒与你
清酒与你 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:33

    In your second example, you're using a.x() as if it were a function: a.x(neg=True). With this in mind, why not just define it as a function?

提交回复
热议问题