Skip to content

Instantly share code, notes, and snippets.

@lloc
Created October 1, 2011 15:24
Show Gist options
  • Save lloc/1256177 to your computer and use it in GitHub Desktop.
Save lloc/1256177 to your computer and use it in GitHub Desktop.
Python slot example
>>> class example(object):
__slots__ = ["x", "y", "z"]
>>> example = example()
>>> example.x = 0
>>> example.y = '0'
>>> example.z = 'Null'
>>> example.a = 0
Traceback (most recent call last):
File "", line 1, in ?
example.a = 0
AttributeError: 'example' object has no attribute 'a'
>>>
@lloc
Copy link
Author

lloc commented Oct 1, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment