python中descriptor的应用

python中descriptor的应用

1、classmethod。

  1)classmethod的应用。

  

  2)classmethod原理。

  

2、staticmethod。

  1)staticmethod应用。

  

  2)staticmethod的原理。

  

3、property。

  1)property的使用。

  

  如上,因为有x = property(...),所以在使用x时,x表示成实例变量。若写成x=3,则x为类对象变量。

  2)property的原理。

  

参考:https://docs.python.org/2.7/howto/descriptor.html

原文地址:https://www.cnblogs.com/tekkaman/p/3727768.html