O'Reilly logo

Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython by Richard Hightower

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Inheritance

Inheritance allows you to reuse common code and so has a profound effect on the way you implement your Python classes. It also allows you to organize your classes into a hierarchical arrangement. Classes toward the bottom of the hierarchy inherit from classes higher up (like a family tree). Thus, if you create a class, classB, that inherits behavior and attributes from another class, ClassA, then classB becomes the subclass of classA, and classA becomes the superclass of classB.

A subclass can override or create new behavior and attributes specific to its role. This is called specialization.

The Limits of Inheritance

It may look like one, but inheritance is no silver bullet. In fact, there are reasons to limit its use. Like all good ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required