Created
October 1, 2011 15:24
-
-
Save lloc/1256177 to your computer and use it in GitHub Desktop.
Python slot example
This file contains 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 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' | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Related post: http://lloc.de/slots-in-php-wie-in-python.html