Python With Spyder 11: Objects Part 4 — Inheritance

This is the 11th in a series of videos providing a tutorial on Python 2.7 using Anaconda Python and the Spyder IDE.

This video is the fourth video introducing objects in Python. This video discusses the idea of inheritance.

The source code used in this video can be found here. You can right click on the link and use “Save As” to save the file.

Note: The source code files are plain text files with a “.txt” extention. You will probably want to change the extensions to “.py” after you download them. If you do so, please be aware that if you have Python installed, the file will become executable, so that it will run if you click on it (accidentally or otherwise).

The video is about 26 minutes long.


Next Video: Dictionaries

Video Index: Objects Part 4 — Inheritance

Click on the topics below to jump to that location in the video.

Time Topic
00:00Title Slide
00:26Review example: supermarket products
03:12Define class for milk products
03:23A class with inheritance
03:56Non-dynamic attributes for every instance of a class
04:16Dynamically creating attributes using __init__()
04:41Arguments of __init__() begin with self and include arguments of parent class
05:10Spyder “trick:” split the editor window
06:03Default values for arguments and the value None
08:07Initialization derived from the parent class
09:01Initialization unique to the child class
10:05Using parent class methods
10:59How inheritance works and how names are resolved.
12:08Definition of a second child class inheriting from the Product class
14:48Summary of inheritance so far.
15:18Executing the class (object) definitions
15:34Spyder “trick:” removing the editor window split
15:53Cells in the Spyder editor: The code for each class is in a cell
16:03Execute the code in a cell using cntrl-enter
17:10Create two instances (milk and laudry detergent)
19:58Skipping arguments and using defaults: subsequent variables names must be specified
21:31Spyder: Move console to make it big
21:40Reference values in object attributes
22:25Reference object methods
22:50Error referencing a method
23:10Using dir() to see an object’s attributes and methods
25:20Summary of inheritance in Python

Next Video: Dictionaries

1 thought on “Python With Spyder 11: Objects Part 4 — Inheritance

Leave a Comment

Time limit is exhausted. Please reload CAPTCHA.