The concept of inheritance


#1



I don't understand how we ensure that things are inherited. Is this not just the same as creating two separate classes?


class Customer(object):
    """Produces objects that represent customers."""
    def __init__(self, customer_id):
        self.customer_id = customer_id

    def display_cart(self):
        print "I'm a string that stands in for the contents of your shopping cart!"

class ReturningCustomer(Customer):
    """For customers of the repeat variety."""
    def display_order_history(self):
        print "I'm a string that stands in for your order history!"


#2

Actually, I understand now. Putting ReturningCustomer(Customer) ensures that the customer class is inherited.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.