Skip to content

Instantly share code, notes, and snippets.

@theharveyz
Created December 18, 2016 09:37
Show Gist options
  • Save theharveyz/5b157b1c1779f7814406f01730b742d2 to your computer and use it in GitHub Desktop.
Save theharveyz/5b157b1c1779f7814406f01730b742d2 to your computer and use it in GitHub Desktop.
py的@classmethod, @staticmethod装饰器对比
# -*- coding: utf-8 -*-
class A(object):
def foo(self):
print 'hello A'
@classmethod
def demo(cls):
s = cls()
s.foo()
@staticmethod
def demo1():
s = A()
s.foo()
A.demo() # output: hello A
A.demo1() # output: hello A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment