Created
April 1, 2018 14:36
-
-
Save liweinan/4ca7880728b273aafea60c9fb3bdb414 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dog2: | |
kind = 'canine' # class variable shared by all instances | |
def __init__(self, name): | |
self.name = name # instance variable unique to each instance | |
dogX = Dog2("Yanan") | |
dogY = Dog2("Anan") | |
print(Dog2.kind) | |
print(dogY.kind) | |
print(dogX.kind) | |
Dog2.kind = "hahaha" | |
print(Dog2.kind) | |
print(dogY.kind) | |
print(dogX.kind) | |
Author
liweinan
commented
Apr 1, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment