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:04
not always required when you are using object only the programming though.
0:09
It's really cool that PyCharm has fantastic support for understanding the entire type.
0:15
archy sometimes this is super obvious because it's just one file like we have here with
0:20
a creature, wizard, small animal and dragon.
0:23
But imagine we broke this apart.
0:25
We have a file that contains the wizard and maybe one that contains a small animal
0:29
and another one that contains different types of dragons.
0:32
All of a sudden what piece applies where not super clear.
0:36
We've got our creature based class and we were wizard and our small animal in our
0:40
dragon, you can see the wizard adds an attack function but doesn't override anything.
0:46
The small animal actually changes what get defensive role which it inherited from creature means.
0:53
And the dragon also changed get defensive role,
0:57
you can see all these little owes with up arrows and down arrows.
1:02
These down arrows are meaning it's overridden and the red up arrows mean it's overriding in
1:10
this location. So creature is overriding the Dunder wrapper special method.
1:14
The small animal is overriding get defensive role.
1:18
That's good information right? It's good to have these here like oh this is actually
1:21
you know, we don't have virtual and override as keywords in python but you can
1:25
kind of see that that's happening here but there's more to it if we actually hover
1:29
over them on the left here,
1:31
we hover over this, it'll say we're overriding This is the repr one can't really
1:36
see it, can you says this overrides the repr method in object over here,
1:42
if we hover over the dragon's get defensive role,
1:45
it says it overrides the method in the creature class and if we go to the
1:50
creature class we get something even cooler.
1:53
It says this method, get defensive role is being overridden by two things that derive
1:59
from you small animal and dragon.
2:02
So in this sense, these things are very helpful about knowing how these pieces are
2:06
working together. What thing is replacing the behavior of a base class,
2:10
What thing is actually changing what it's getting from the particular class,
2:15
you're focused on an example of a creature,
2:17
the small animals, changing what that means.
2:18
So be aware that as you work on it and if you actually click on it
2:23
I give you click where it says override Method,
2:25
an object, it'll jump you over to the base class.
2:29
Dunder repr in this case here is where that code lives.
2:32
And in the Dunder reprs actually implemented in c python.
2:35
So you just get this stub thing,
2:37
the built ins. But nonetheless,
2:40
as we click around on those little spots, we actually navigate from base class, derive class so,on.