Created
December 16, 2013 00:32
-
-
Save dsmith/7980516 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(): | |
def __init__(self): | |
self._things = { | |
'thing_one': 10, | |
'thing_two': 10, | |
} | |
def get_thing(self, key): | |
return self._things[key] | |
def things(self): | |
return self._things.keys() | |
class B(A): | |
def __init__(self): | |
self._things = { | |
'thing_one': 20, | |
'thing_two': 10, | |
} | |
a = A() | |
b = B() | |
print 'All the things', a.things() | |
print 'A.thing_one', a.get_thing('thing_one') | |
print 'A.thing_two', a.get_thing('thing_two') | |
print 'B.thing_one', b.get_thing('thing_one') | |
print 'B.thing_two', b.get_thing('thing_two') | |
print 'B.thing_two', b.get_thing('thing_two') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment