Created
May 31, 2009 01:51
-
-
Save jspeis/120708 to your computer and use it in GitHub Desktop.
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 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