Python - why can I call a class method with an instance?
问题 New to Python and having done some reading, I'm making some methods in my custom class class methods rather than instance methods. So I tested my code but I hadn't changed some of the method calls to call the method in the class rather than the instance, but they still worked: class myClass: @classmethod: def foo(cls): print 'Class method foo called with %s.'%(cls) def bar(self): print 'Instance method bar called with %s.'%(self) myClass.foo() thing = myClass() thing.foo() thing.bar() This