Skip to content

Instantly share code, notes, and snippets.

@jnschaeffer
Created April 6, 2014 19:58
Show Gist options
  • Select an option

  • Save jnschaeffer/10010792 to your computer and use it in GitHub Desktop.

Select an option

Save jnschaeffer/10010792 to your computer and use it in GitHub Desktop.
Attributes in Python
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