Skip to content

Instantly share code, notes, and snippets.

@JackInTaiwan
Created October 1, 2018 16:57
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 JackInTaiwan/16d344a34f9fd6e3ef086dc77fd26d10 to your computer and use it in GitHub Desktop.
Save JackInTaiwan/16d344a34f9fd6e3ef086dc77fd26d10 to your computer and use it in GitHub Desktop.
python_advanced_private_3
class Animal:
def __init__(self):
self.__alive = True
self.__age = 0
def get_age(self):
return self.__age
def add_age(self):
self.__age += 1
dog = Animal()
print(dog.get_age())
# 0
dog.add_age()
print(dog.get_age())
# 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment