Skip to content

Instantly share code, notes, and snippets.

@eskerda
Created June 27, 2012 07:08
Show Gist options
  • Save eskerda/3002163 to your computer and use it in GitHub Desktop.
Save eskerda/3002163 to your computer and use it in GitHub Desktop.
class Base(object):
things = []
def update(self):
print "I do nothing"
class A(Base):
def update(self):
self.things.append('This is A')
class B(Base):
def update(self):
self.things.append('This is B')
a = A()
b = B()
a.update()
a.update()
a.update()
a.update()
a.update()
print "A things are: %s" % a.things
print "B thigs are: %s" % b.things
"""
OUTPUT
python2.7 wtf.py
A things are: ['This is A', 'This is A', 'This is A', 'This is A', 'This is A']
B thigs are: ['This is A', 'This is A', 'This is A', 'This is A', 'This is A'
Why does B have things??
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment