Last active
August 29, 2015 14:24
-
-
Save wjwwood/b3f4d3a11dc7d767a90b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 A(object): | |
| ... def __init__(self): | |
| ... self.__foo = 'bar' | |
| ... @property | |
| ... def foo(self): | |
| ... return self.__foo | |
| ... | |
| >>> a = A() | |
| >>> a.foo | |
| 'bar' | |
| >>> a.foo = 'baz' | |
| Traceback (most recent call last): | |
| File "<stdin>", line 1, in <module> | |
| AttributeError: can't set attribute | |
| >>> a._A__foo = 'baz' | |
| >>> a.foo | |
| 'baz' | |
| >>> a.__foo | |
| Traceback (most recent call last): | |
| File "<stdin>", line 1, in <module> | |
| AttributeError: 'A' object has no attribute '__foo' | |
| >>> a._A__foo | |
| 'baz' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment