Skip to content

Instantly share code, notes, and snippets.

@erlnby
Last active June 4, 2020 06:26
Show Gist options
  • Save erlnby/11daf5b7c7566c0673ba7e1d5dbc57ed to your computer and use it in GitHub Desktop.
Save erlnby/11daf5b7c7566c0673ba7e1d5dbc57ed to your computer and use it in GitHub Desktop.
The obvious difference between @staticmethod and @classmethod in Python
class A:
a = 123
@staticmethod
def sF():
print(A.a)
@classmethod
def cF(cls):
print(cls.a)
class B(A):
a = 321
B.sF() #123
B.cF() #321
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment