首页 > 编程语言 > 详细

Python @classmethod&@staticmethod 区别

时间:2015-12-25 18:39:14      阅读:198      评论:0      收藏:0      [点我收藏+]

转自Stackoverflow
@classmethod means: when this method is called, we pass the class as the first argument instead of the instance of that class (as we normally do with methods). This means you can use the class and its properties inside that method rather than a particular instance.

@staticmethod means: when this method is called, we don‘t pass an instance of the class to it (as we normally do with methods). This means you can put a function inside a class but you can‘t access the instance of that class (this is useful when your method does not use the instance).

 

Python @classmethod&@staticmethod 区别

原文:http://www.cnblogs.com/yaoshi/p/5076413.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!