Skip to content

Instantly share code, notes, and snippets.

@cjw296
Created February 18, 2019 17:05
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cjw296/450bdd5aaf9c3156b8e4df7dde81c76f to your computer and use it in GitHub Desktop.
>>> class Wut(object):
... __slots__ = ('a',)
...
>>> Wut()
<__main__.Wut object at 0x7ffff7f55b40>
>>> Wut().b = 1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Wut' object has no attribute 'b'
>>> class Eva(Wut): pass
...
>>> Eva().b = 1
>>> Eva()
<__main__.Eva object at 0x7ffff1be8098>
>>> vars(Eva())
{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment