text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
programming but what we thought we do is
8,273.96
4.88
focus really on some final core features
8,275.96
4.519
that you see not just in Python but
8,278.84
3.799
other languages as well and perhaps one
8,280.479
3.801
of the most compelling features of
8,282.639
3.241
object-oriented programming that we
8,284.28
3.88
haven't yet used explicitly though it
8,285.88
4.639
turns out we've seen implicitly over the
8,288.16
5.399
past weeks is this notion of inheritance
8,290.519
5.04
it turns out via object-oriented
8,293.559
3.241
programming there's actually an
8,295.559
4.561
opportunity to design your classes in a
8,296.8
5.719
hierarchical fashion whereby you can
8,300.12
6.439
have one class inherit from or borrow
8,302.519
6.88
attributes that is methods or variables
8,306.559
5.241
from another class if they all have
8,309.399
5
those in common so what do I mean by
8,311.8
5.16
this here well let me propose that we
8,314.399
5.28
Implement uh over in vs code here a
8,316.96
5.359
brand new file called wizard. piy let me
8,319.679
6.161
go ahead and run code of wizard. piy and
8,322.319
6.04
then let's start as before for defining
8,325.84
5.04
a class called student and let's go
8,328.359
4.441
ahead and first Define the underscore
8,330.88
4.32
uncore init method which of course is
8,332.8
3.799
minimally going to take an argument
8,335.2
3.119
traditionally called self and in this
8,336.599
3.441
case let's also have it take as before a
8,338.319
4.441
name and a house and then in this init
8,340.04
4.72
method let's go ahead and assign the
8,342.76
4.759
instance variables self. name equals
8,344.76
6.599
name and self. house equals house let's
8,347.519
5
assume that there's some other
8,351.359
3.08
functionality in this class as well dot
8,352.519
3.721
dot dot but let's move on now to
8,354.439
3.761
implementing the notion of a a professor
8,356.24
4.56
in The Wizarding World as well so for
8,358.2
5.519
this class let's call it
8,360.8
5.559
professor and a professor let's say is
8,363.719
4.121
also going to have its own
8,366.359
3.32
initialization method so underscore
8,367.84
3.839
underscore in it it's going to take self
8,369.679
4.161
as always as the first argument uh a
8,371.679
4.161
professor also has a name so we'll pass
8,373.84
4.4
that in second to and even though some
8,375.84
4.2
professors are heads of houses let's
8,378.24
3.239
assume that a professor is really
8,380.04
2.92
identified by their name and their
8,381.479
3.84
subject area the class that they teach
8,382.96
4.16
so we'll call this third argument
8,385.319
3.881
subject subject now as before let's go
8,387.12
4.8
ahead and assign self. name equals name
8,389.2
5.96
and let's assign self. sub equals
8,391.92
5.32
subject here and as before let's assume
8,395.16
3.48
that there's some more functionality
8,397.24
4.04
associated with professors as well well
8,398.64
4.799
what do you notice already here in my
8,401.28
5.039
definitions of students and
8,403.439
5.081
professors typically we're a bit
8,406.319
4.681
reluctant to allow for any redundancy in
8,408.52
5.36
our code and here I feel like my init
8,411
5
method is taking a name for students my
8,413.88
4.12
init method is also taking name for a
8,416
3.479
professor and I have these identical
8,418
3.96
lines of code like self. name equals
8,419.479
3.84
name and this is only going to get
8,421.96
3.2
exacerbated if I now go and add some
8,423.319
4.321
error checking so for instance How about
8,425.16
5.48
if uh if not name we should probably be
8,427.64
4.679
in the habit of raising something like a
8,430.64
3.96
value error and an explanatory message
8,432.319
5.12
like missing name and you know what if a
8,434.6
4.6
professor is missing their name I should
8,437.439
3.561
probably copy paste that code down here
8,439.2
3.68
and that's where Red Flag should be
8,441
3.6
going off whereby as soon as you start
8,442.88
4.64
copy pasting code there's probably a
8,444.6
4.68
better way so that we can write the code
8,447.52
3.959
once and perhaps reuse it in some way
8,449.28
4.36
and here too object-oriented programming
8,451.479
4.721
offers a solution it turns out that
8,453.64
4.24
object-oriented programming in Python
8,456.2
4.68
also supports inheritance whereby you
8,457.88
5.88
can Define multiple classes that somehow
8,460.88
4.68
relate to one another they don't need to
8,463.76
3.92
exist sort of in parallel in this way
8,465.56
3.799
there could actually be some hierarchy
8,467.68
3.4
between them so for instance in The
8,469.359
3.561
Wizarding World we could argue that both
8,471.08
3.92
a student and a professor are at the end
8,472.92
4.64
of the day Wizards so maybe what should
8,475
4.6
really Define is a third class for
8,477.56
4.32
instance called wizard that has any of
8,479.6
5.36
the common attributes for students and
8,481.88
4.599
professors alike and for now we've kept
8,484.96
3.16
it relatively simple the only thing they
8,486.479
4.121
have in common is a name and a name in
8,488.12
4.319
student and Professor respectively so
8,490.6
4.12
why don't we minimally factor that out
8,492.439
4.681
first all right so let me go ahead here
8,494.72
3.88