Skip to content

Instantly share code, notes, and snippets.

@jspeis
Created May 31, 2009 01:51
Show Gist options
  • Save jspeis/120708 to your computer and use it in GitHub Desktop.
Save jspeis/120708 to your computer and use it in GitHub Desktop.
class A():
test = 'Everyone'
def __init__(self):
self.local = 'Just Me'
def __str__(self):
return self.test + " " + self.local
x = A()
y = A()
x.local = 'I am X'
x.test2 = 'me' # just making up a new instance var
#x.test = 'Not me!' # note, we are going to make up a new instance var overwriting the class var!
A.test = 'Everyone will have this' # should change every instances class var
# (but uncomment the x.test .. line and see what happens when you change a class variable
# using a particular instance
print x
print y
print x.test2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment