Effective PyCharm Transcripts
Chapter: The Editor
Lecture: Object-oriented features

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Python is a great language, it has super support for object oriented programming but it's
0:05 not always required when you are using object only the programming though.
0:10 It's really cool that PyCharm has fantastic support for understanding the entire type.
0:16 archy sometimes this is super obvious because it's just one file like we have here with a creature, wizard, small animal and dragon.
0:24 But imagine we broke this apart. We have a file that contains the wizard and maybe one that contains a small animal
0:30 and another one that contains different types of dragons. All of a sudden what piece applies where not super clear.
0:37 We've got our creature based class and we were wizard and our small animal in our
0:41 dragon, you can see the wizard adds an attack function but doesn't override anything.
0:47 The small animal actually changes what get defensive role which it inherited from creature means. And the dragon also changed get defensive role,
0:58 you can see all these little owes with up arrows and down arrows.
1:03 These down arrows are meaning it's overridden and the red up arrows mean it's overriding in
1:11 this location. So creature is overriding the Dunder wrapper special method. The small animal is overriding get defensive role.
1:19 That's good information right? It's good to have these here like oh this is actually
1:22 you know, we don't have virtual and override as keywords in Python but you can
1:26 kind of see that that's happening here but there's more to it if we actually hover over them on the left here,
1:32 we hover over this, it'll say we're overriding This is the repr one can't really
1:37 see it, can you says this overrides the repr method in object over here, if we hover over the dragon's get defensive role,
1:46 it says it overrides the method in the creature class and if we go to the creature class we get something even cooler.
1:54 It says this method, get defensive role is being overridden by two things that derive from you small animal and dragon.
2:03 So in this sense, these things are very helpful about knowing how these pieces are
2:07 working together. What thing is replacing the behavior of a base class, What thing is actually changing what it's getting from the particular class,
2:16 you're focused on an example of a creature, the small animals, changing what that means.
2:19 So be aware that as you work on it and if you actually click on it I give you click where it says override Method,
2:26 an object, it'll jump you over to the base class. Dunder repr in this case here is where that code lives.
2:33 And in the Dunder reprs actually implemented in c Python. So you just get this stub thing, the built ins. But nonetheless,
2:41 as we click around on those little spots, we actually navigate from base class, derive class so,on.


Talk Python's Mastodon Michael Kennedy's Mastodon