Created
August 21, 2014 11:18
-
-
Save InFog/c501ce498b104ef0c5f1 to your computer and use it in GitHub Desktop.
Example of Python's parent __init__ with super (Python 2)
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 Person(object): | |
def __init__(self, name): | |
self.name = name | |
class Customer(Person): | |
def __init__(self, name, credit): | |
super(Customer, self).__init__(name) | |
self.credit = credit | |
def __str__(self): | |
return "Name: %s, Credit: $ %.2f" % (self.name, self.credit) | |
c = Customer("John", 9) | |
print c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment