Skip to content

Instantly share code, notes, and snippets.

@tanishiking
Last active February 20, 2016 14:31
Show Gist options
  • Save tanishiking/d3e475e3abe511878c7d to your computer and use it in GitHub Desktop.
Save tanishiking/d3e475e3abe511878c7d to your computer and use it in GitHub Desktop.
class hoge:
def __init__(self):
self.a = 1
def __get_a(self):
return self.a
def geta(self):
# 普通に __get_a()にアクセスできる
a = self.__get_a()
return a
if __name__ == '__main__':
h = hoge()
print(h.geta()) # print 1
# h.__get_a() は Attribute Error になるが...
print(h._hoge__get_a()) # print 1 !!!!!
@tanishiking
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment