Created
February 20, 2013 20:00
-
-
Save poundifdef/4998930 to your computer and use it in GitHub Desktop.
This file contains 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 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