What is the difference between @staticmethod and @classmethod?
问题 What is the difference between a function decorated with @staticmethod and one decorated with @classmethod? 回答1: Maybe a bit of example code will help: Notice the difference in the call signatures of foo , class_foo and static_foo : class A(object): def foo(self, x): print "executing foo(%s, %s)" % (self, x) @classmethod def class_foo(cls, x): print "executing class_foo(%s, %s)" % (cls, x) @staticmethod def static_foo(x): print "executing static_foo(%s)" % x a = A() Below is the usual way an