Skip to content

Instantly share code, notes, and snippets.

@gotraveltoworld
Last active May 19, 2019 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gotraveltoworld/d2a754464a5170d791122810a53bf7c3 to your computer and use it in GitHub Desktop.
Save gotraveltoworld/d2a754464a5170d791122810a53bf7c3 to your computer and use it in GitHub Desktop.
To show the Static_Class_method.
class First(object):
def member1(self, n):
return n
@classmethod
def member2(cls, n):
# Call the static member.
n += cls.member3(n)
# Call the normal member.
n += cls.member1(cls, n)
return n
@staticmethod
def member3(n):
return n
print('Member1(normal member):', First().member1(1)) # 1
print('Member2(class member):', First.member2(1)) # 4
print('Member3(static member):', First.member3(1)) # 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment