Hi all,
I just started reading Python3 OOP (Dusty Phillips), and I am using Python3, Idle3 interpreter on Kubuntu Linux 11.10 for playing with the examples. In following the override example in Chapter 3, I have an entity class with a standard subclass and one that overrides the superclass. Even following the example almost verbatim, my Family class fails when I try to create a Family entity at run-time. The Supplier subclass works fine, but when I try to override the Entity class in the Family class, it fails.
The sample class in the book is "Contact" (I call it Entity). The author is showing how, if you have a class with a name and e-mail, you can create a subclass of Contacts with phone numbers:
#Class
class Entity:
all_entities = []
def __init__(self, name, email):
self.name = name
self.email = email
Entity.all_entities.append(self)
class Supplier(Entity):
def order(self, order):
print("If this were a real system we would send "
"{} order to {}".format(order, self.name))
class Family(Entity):
def __init__(self, name, email, phone):
super().__init__(name, email)
self.phone = phone
# Sample run
>>> f = Family("Don", "d...@somedomain.net", "7043657300")
Traceback (most recent call last):
File "<pyshell#18>", line 1, in <module>
f = Family("Don", "d...@somedomain.net", "7043657300")
TypeError: __init__() takes exactly 5 arguments (4 given)
I do note that the __init__() shows empty. In another iteration, the () had values in them (the variable names), and I received a lower number of parameters than were really supposed to be. Can anyone tell me what I am missing?
Thanks!
Don
--
You received this message because you are subscribed to the Google Groups "Charlotte Python Group" group.
To view this discussion on the web visit https://groups.google.com/d/msg/charpy/-/0WVs42YdrKMJ.
To post to this group, send email to cha...@googlegroups.com.
To unsubscribe from this group, send email to charpy+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/charpy?hl=en.