Created
April 6, 2014 19:58
-
-
Save jnschaeffer/10010792 to your computer and use it in GitHub Desktop.
Attributes in Python
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 SomeClass(object): | |
| x = 1 | |
| y = 2 | |
| def __init__(self, z): | |
| self.z = 0 # New attribute created | |
| delattr(self, 'z') # Attribute deleted--throws error if you try to access it | |
| def some_method(self): | |
| self.b = 1 # New attribute created |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment