且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Python中实现方法,类方法和静态方法?

更新时间:2022-12-05 07:57:49

检查一下.

http://docs.python.org/howto/descriptor.html#static-methods-and-class-methods

您还可以在funcobject.c中查看类和静态方法对象的源代码:

You can also take a look at the source code for class and static method objects, in funcobject.c:

http://hg.python.org/cpython/file/69b416cd1727/Objects/funcobject.c

类方法对象定义从第694行开始,而静态方法对象定义从第852行开始.(我确实发现,当methodobject.c也存在时,它们在funcobject.c中具有名为"method"的项有点可笑.)

Class method object definition starts on line 694, while static method object definition starts on line 852. (I do find it kind of funny that they have items titled "method" in funcobject.c when methodobject.c also exists.)