Skip to content

Instantly share code, notes, and snippets.

@poundifdef
Created February 20, 2013 20:00
Show Gist options
  • Save poundifdef/4998930 to your computer and use it in GitHub Desktop.
Save poundifdef/4998930 to your computer and use it in GitHub Desktop.
class Parent(object):
def __init__(self, username, password):
self.username = username
self.password = password
def _get_name(self):
return self.username.upper()
def child_action(self):
return Child(self.username, self.password)
class Child(Parent):
def __init__(self, username, password):
self.username = username
self.password = password
@property
def car_type(self):
if self.username == 'john':
return self._get_name() + ' Chevy'
foo = Parent('john', 'passwd')
print foo.child_action().car_type
bar = Parent('joe', 'passwd')
print bar.child_action().car_type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment