Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class Foo(object):
def __init__(self):
self.public = 'public'
self._protected = 'protected'
self.__private = 'private'
obj = Foo()
print(obj.public)
print(obj._protected)
print(obj.__private)
# Result :
#
# $ python test1.py
# public
# protected
# Traceback (most recent call last):
# File "test1.py", line 10, in <module>
# print(obj.__private)
# AttributeError: 'Foo' object has no attribute '__private'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.