Object Oriented Python by Example ---------------------------------------- Let's take a second pass at object oriented programming in Python. Object oriented programming is about creating new types to model data used in the program. Python Person (person.py) ---------------------------------------- .. literalinclude:: /code/person.py Extending Person ---------------------------------------- In object oriented programming in inheritance defines an "is a" relationship between types. To continue the example we could say a student is a person. This would create a Student class which is a sub-class of Person. Students have things that normal people don't have like a GPA. Using ``super`` ---------------------------------------- Extending the class allows us to extend or override the functionally given by the base. If we don't override a name in the new class accessing that name will use functionality defined in the base. If we do override a name it we can still access the base class definition using ``super``. Extending Person (student.py) ---------------------------------------- .. literalinclude:: /code/student.py .. header:: MA792K Spring 2011 Lecture 3 (Again) .. footer:: © Mark Lavin 2011