From the course: Transition from C# to Python

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Inheritance

Inheritance

From the course: Transition from C# to Python

Start my 1-month free trial

Inheritance

- [Instructor] All right, so now that we've seen how to create basic classes, let's take a look at how Python inheritance works. And once again, let's open up the C# version of the code. And that's in the inheritance folder inside inheritanceCS. And you can see now that I've factored out a base class called Publication, and that contains the title and the price properties and Book is now a subclass of the Publication and the Book now only contains the author property. And when the book object is instantiated, right, you can see that I'm using the base keyword here to initialize the base class first, and then my code sets the author property. And everything else is pretty much the same as in the previous example. So let's open up the Python code. So now we're going to change our Book class to inherit from a base class named Publication. And you can see, by the way, I filled out the properties for the other properties,…

Contents