Python @property decorator not working

后端 未结 1 1287
猫巷女王i
猫巷女王i 2020-12-11 16:53

Could anyone find a problem with this @property decorator? I cannot seem to get it to assert correctly. I\'m sure I\'m doing some really simple thing wrong, but can anyone p

相关标签:
1条回答
  • 2020-12-11 17:16

    The @property decorator only works on new style classes. Inherit from object:

    class A(object):
    

    With that change your test function passes.

    0 讨论(0)
提交回复
热议问题