Skip to content

Instantly share code, notes, and snippets.

@rectalogic
Created October 11, 2016 13:19
Show Gist options
  • Save rectalogic/1450095191acbf4488cd048fa5dea3b6 to your computer and use it in GitHub Desktop.
Save rectalogic/1450095191acbf4488cd048fa5dea3b6 to your computer and use it in GitHub Desktop.
>>> class Foo(object):
... __slots__ = ("e",)
... e = None
...
>>> f = Foo()
>>> f.e = "x"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Foo' object attribute 'e' is read-only
>>> f.e
>>> class Foo(object):
... e = None
...
>>> f = Foo()
>>> f.e
>>> f.e = "X"
>>> f.e
'X'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment