text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
and just to keep things organized at the | 8,497.12 | 3.239 |
top of my file let's define a third | 8,498.6 | 4.32 |
class called Wizard and a wizard will | 8,500.359 | 4.801 |
have its own initialization method so | 8,502.92 | 5.36 |
decore uncore init underscore uncore and | 8,505.16 | 5.52 |
self as always and a wizard let's say | 8,508.28 | 4.88 |
for now is only going to be initialized | 8,510.68 | 5.84 |
with their name in this way and now I'm | 8,513.16 | 4.64 |
going to go ahead and do some of that | 8,516.52 | 3.16 |
error checking so if not name we'll | 8,517.8 | 4.8 |
raise a value error in the Wizard class | 8,519.68 | 5.04 |
otherwise we'll go ahead and do self. | 8,522.6 | 4.719 |
name equals name and heck dot dot dot | 8,524.72 | 4.88 |
maybe some other functionality as well | 8,527.319 | 4.201 |
but not a subject which is specific to | 8,529.6 | 3.68 |
professors and not a house which I've | 8,531.52 | 4.28 |
claimed is specific to students now I | 8,533.28 | 5 |
think we can begin to maybe remove some | 8,535.8 | 4.599 |
of the redundancies in our other classes | 8,538.28 | 5.44 |
here so for instance down with student | 8,540.399 | 5.281 |
why don't I go ahead and remove this | 8,543.72 | 4.12 |
error checking here and remove this | 8,545.68 | 4.719 |
error this assignment of self. name | 8,547.84 | 4.44 |
equals name because I'm already doing | 8,550.399 | 3.881 |
that in Wizard and similarly down here | 8,552.28 | 3.52 |
in Professor why don't I do the same | 8,554.28 | 3.119 |
let's get rid of the error checking | 8,555.8 | 3.559 |
let's get rid of self. name equals name | 8,557.399 | 3.481 |
because I'm again I'm doing that already | 8,559.359 | 4.241 |
up there for Wizard as well but at the | 8,560.88 | 4.28 |
moment even though they're all in the | 8,563.6 | 3.96 |
same file I haven't told python that a | 8,565.16 | 4.8 |
student is a wizard and a professor is a | 8,567.56 | 4.36 |
wizard so I really need to link these | 8,569.96 | 3.92 |
two together and the way you can | 8,571.92 | 5.08 |
prescribe inheritance whereby one class | 8,573.88 | 4.92 |
should inherit from another or | 8,577 | 4 |
conversely one class should descend for | 8,578.8 | 4.76 |
another from another we can do this I | 8,581 | 4.72 |
can say class student but before the | 8,583.56 | 4.759 |
colon I can go in and say in parenthesis | 8,585.72 | 6.04 |
a student inherits from or is a subclass | 8,588.319 | 6.321 |
of wizard which conversely is the super | 8,591.76 | 5.8 |
class of the student class so this means | 8,594.64 | 4.96 |
that when I Define a student class go | 8,597.56 | 3.52 |
ahead and inherit all of the | 8,599.6 | 4.32 |
characteristics of a wizard as well and | 8,601.08 | 4.44 |
I'm going to do the same thing for her | 8,603.92 | 4.519 |
for Professor so parenthesis wizard | 8,605.52 | 4.6 |
after the class name professor and | 8,608.439 | 3.281 |
that's going to give me access to some | 8,610.12 | 2.88 |
of that same | 8,611.72 | 3.8 |
functionality but because my student | 8,613 | 4.68 |
class and my professor class still have | 8,615.52 | 4.44 |
their same init methods those are the | 8,617.68 | 3.44 |
methods that are going to get called | 8,619.96 | 3.2 |
whenever I create a student in code or I | 8,621.12 | 4.359 |
create a professor in code I need to | 8,623.16 | 4.4 |
somehow explicitly say that I also want | 8,625.479 | 4.481 |
to use the functionality in the Wizard | 8,627.56 | 5.08 |
classes init method and the way to do | 8,629.96 | 4.92 |
this in Python is is as follows let me | 8,632.64 | 4.48 |
go into my init method for student and | 8,634.88 | 4.76 |
let me call Super with no arguments | 8,637.12 | 5.04 |
which is a reference to the super class | 8,639.64 | 4.52 |
of this class so if this class is | 8,642.16 | 3.76 |
student the super class that is the | 8,644.16 | 4.8 |
parent class is Wizard so super open | 8,645.92 | 5.8 |
paren Clos paren will have the effect of | 8,648.96 | 5.68 |
accessing the super class and then I'm | 8,651.72 | 4.679 |
going to go ahead and explicitly call | 8,654.64 | 4.08 |
its in it method and I'm going to pass | 8,656.399 | 6.121 |
to the Wizards init method the name that | 8,658.72 | 6.48 |
the students init method was passed and | 8,662.52 | 4.24 |
I'm going to go ahead and do the same | 8,665.2 | 3.6 |
down here in Wizard this is one line of | 8,666.76 | 4.44 |
copy paste but I think I'm okay with it | 8,668.8 | 4 |
here because it's still allowing me to | 8,671.2 | 3.079 |
do all of the name assignment and the | 8,672.8 | 3.4 |
error checking up in the Wizard class | 8,674.279 | 4.761 |
instead I think we're okay now by just | 8,676.2 | 6.159 |
calling super. init for both student and | 8,679.04 | 5.6 |
Professor alike now admittedly this | 8,682.359 | 4.721 |
syntax is definitely out there the fact | 8,684.64 | 4.16 |
that we're calling super and parentheses | 8,687.08 | 3.56 |
and dots and underscore underscore on | 8,688.8 | 3.96 |
the left and the right of init here but | 8,690.64 | 3.56 |
it's just a combination of these two | 8,692.76 | 3.76 |
ideas super open parenthesis closed | 8,694.2 | 4.36 |
parenthesis is a way of programmatically | 8,696.52 | 4.56 |
accessing a current class's parent class | 8,698.56 | 4.799 |
or super class and underscore uncore in | 8,701.08 | 4.12 |
it of course is just referring to now | 8,703.359 | 4.881 |
that class's own initialization method | 8,705.2 | 4.56 |
now per the dot dot dots there could be | 8,708.24 | 3.28 |
a lot more going on in these classes but | 8,709.76 | 4.84 |
what's nice now is that wizard as a | 8,711.52 | 4.919 |
class is taking care of all of the | 8,714.6 | 3.759 |
assignments of a Wizard's name whether | 8,716.439 | 3.92 |
that wizard is a student or a professor | 8,718.359 | 3.521 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.