Skip to content

Instantly share code, notes, and snippets.

@ZhouYang1993
Last active April 22, 2020 11:20
Show Gist options
  • Save ZhouYang1993/e038126c3362f209b3e10b1e80202294 to your computer and use it in GitHub Desktop.
Save ZhouYang1993/e038126c3362f209b3e10b1e80202294 to your computer and use it in GitHub Desktop.
Differences between Class Attribute and Instance Attribute of Python
class HandsomeGuy(object):
name = 'Yang'
def __init__(self, value):
self.name = value
guy = HandsomeGuy('Jack')
HandsomeGuy.name
# 'Yang'
guy.name
# 'Jack'
del guy.name
guy.name
# 'Yang'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment