Glossary · Phase 0 · Tools
Subclass
A class built on another class with inheritance, such as class Rental(Product).
class Rental(Product):makesRentala subclass ofProduct: it gets every attribute and methodProducthas.Productis the parent class.
Try it now
Creating the Rental runs Rental's __init__, which calls Product's __init__ through super(). Watch two frames for the same object, one stacked on the other.
Learn it properly
Inheritance and class attributes · Build classes on other classes, and share values across every object. About 35 minutes.
Other terms from the same lesson
- class attribute: A value written in a class's body, outside any method, and shared by every object of that class.
- inheritance: Building a new class on an existing one, so it gets everything the old class has and can change or add to it.
Never trained an AI?
Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account.