摘要: 普通的方法,第一个参数需要是self,它表示一个具体的实例本身。如果用了staticmethod,那么就可以无视这个self,而将这个方法当成一个普通的函数使用。而对于classmethod,它的第一个参数不是self,是cls,它表示这个类本身。>>> class A(object): def foo1(self): print "Hello",self @staticmethod def foo2(): print "hello" @classmethod def foo3(cls): print "hello" 阅读全文
posted @ 2013-03-14 22:59 SA高处不胜寒 阅读(29580) 评论(0) 推荐(5) 编辑