#staticVsClassMethod.py class MyClass(): def anyFunction(self): print "I am any function" @staticmethod def myStaticFunction(): print "I am static method" @classmethod def myClassFunction(cls): print "I am class method" print cls MyClass.myStaticFunction() MyClass.myClassFunction() #MyClass.anyFunction() #this is not possible, need a object instance
Output:
I am static method I am class method __main__.MyClass
0 comments:
Post a Comment