Source Code:
(back to article)
class MyClass: def __init__(self): self.__private = "private attribute" self.public = "public attribute" obj = MyClass() print(obj.public) # Output: "public attribute" print(obj.__private) # AttributeError: 'MyClass' object has no attribute '__private'
Result:
Report an issue