Created
October 15, 2015 23:24
-
-
Save kennethlove/2a84bcafc855bb75c9f1 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 Person: | |
first_name = None | |
last_name = None | |
def get_name(self): | |
return first_name, last_name | |
class Friend(Person): | |
def get_name(self): | |
#name = super(Friend, self).get_name() # Python 2 version | |
name = super().get_name() # Python 3 | |
return name[0] | |
kenneth = Person() | |
kenneth.first_name = "Kenneth" | |
kenneth.last_name = "Love" | |
kenneth.get_name() # outputs ("Kenneth", "Love") | |
craig = Friend() | |
craig.first_name = "Craig" | |
craig.last_name = "Dennis" | |
craig.get_name() # outputs "Craig" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment