Web Development: Learn Inheritance in Python 3


show more Understanding inheritance provides you with in-depth training on Developer. Taught by Bill Weinman as part of the Python 3 Essential Training show less
please wait ...

Understanding inheritance

In object-oriented programming, inheritance is when one class inherits the properties of another class. The class that is being inherited from is often called a base class or a parent class. Let's take a look at how this is done in Python. We'll start by making a working copy of classes.py, classes-working.py, and we'll open our working copy. You notice that we have this Duck class here. We're going to create another class. We'll call this one Animal.

So the Animal class will have methods in it that will be inherited by the Duck class and perhaps other animals as well. We'll start by saying that an animal makes a sound, so we'll call talk and that will print 'I have something to say!', and say that the animal moves around. We'll call that walk, print. 'Hey! I' 'm walkin'' here!' And then an animal is covered with something, usually fur or feathers or something. We'll call that clothes.

'I have nice clothes'. [00:01:22.0...

Understanding inheritance
Video duration: 5m 11s 6h 36m Beginner

Viewers:

Understanding inheritance provides you with in-depth training on Developer. Taught by Bill Weinman as part of the Python 3 Essential Training

Subjects:
Developer Web
Software:
Python
Author:
please wait ...