Python for .NET Developers Transcripts
Chapter: Course conclusion
Lecture: Object-oriented Python review

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Next up on our Pythonic journey were classes, and objects and object oriented programming. And you saw that Python has a rich, proper
0:09 object orientated programming model. We have private data, we have public data, we have methods we have abstract methods, we have properties.
0:17 It's not as full featured as C#'s object orientated model. For example, we can't reasonably have protected values without conventions.
0:27 We do have these private values here but protected is more of a suggestion. In Python, you also don't have, for example
0:35 virtual versus non virtual methods and you can override the virtual ones but not the non virtual ones without a warning.
0:41 Right, so there are some things that are not there but it's most of the important stuff you're going to use day to day, it's there.
0:47 So here we're going to define a car class that's abstract so it derives from ABC, abstract base class remember how we imported that.
0:55 One of the bigger differences is the way we define fields is in the constructor or in the dunder init initializer method here.
1:02 So we say self dot model name equals model name and that actually defines the field as an instance variable on this type.
1:09 Right, in C# this would be outside of the constructor you would define private field such and such or public field such an such.
1:17 Once you get used to this, though, it's totally fine it's just different. We also have a regular function we have, which is drive.
1:24 We have a property, which is is electric so that's a computer property. And we have abstract methods as well and that's our refuel.
1:32 You want to drive from car class and be implemented or instantiated you've got to implement refuel.

Talk Python's Mastodon Michael Kennedy's Mastodon