Creating a method that is simultaneously an instance and class method

前端 未结 1 1516
走了就别回头了
走了就别回头了 2020-12-09 04:11

In Python, I\'d like to be able to create a function that behaves both as a class function and an instance method, but with the ability to change behaviors. The use case for

相关标签:
1条回答
  • 2020-12-09 04:52

    Sure, you just need to define your own descriptor type. There's an excellent tutorial on Python descriptors here.

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