text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
and it's called exactly this this is
2,425.24
3.92
designed by the authors of python and if
2,427.079
5.441
you want to initialize the contents of
2,429.16
6
an object from a class you define this
2,432.52
4.16
method and we'll see what it's about to
2,435.16
4.36
do here let me go back to vs code and
2,436.68
6
let me do something like this self. name
2,439.52
8.44
equals name and self. house equals house
2,442.68
7.12
but I don't want to just init this
2,447.96
4.04
object very generically I want this
2,449.8
5.08
method called in it to take in not just
2,452
6.599
self but name comma house as well now
2,454.88
5.12
what in the world is going on because
2,458.599
3
there's a lot of weird syntax here
2,460
3.599
there's this Dunder init method double
2,461.599
4.201
underscore in it double underscore
2,463.599
4.081
there's all of a sudden this parameter
2,465.8
3.84
called self and then there's this new
2,467.68
5.159
syntax self. name and self. house now
2,469.64
5.24
you're seeing really a manifestation of
2,472.839
4.321
objectoriented programming it's not all
2,474.88
3.52
that different fundamentally from what
2,477.16
2.48
we've been doing for weeks with
2,478.4
3.76
dictionaries by adding keys to
2,479.64
4.6
dictionaries but in this case we're
2,482.16
6.199
adding variables to to objects AKA
2,484.24
6.48
instance variables to objects now what's
2,488.359
4.201
going on let's do this in Reverse let's
2,490.72
3.24
go back to the line of code we wrote
2,492.56
4.559
earlier on line 15 I am treating the
2,493.96
5.72
name of this class student with a
2,497.119
6.401
capital S as a function and I am passing
2,499.68
6.639
in two values name and house what I've
2,503.52
4.2
highlighted here on the screen on line
2,506.319
4.321
15 is generally known as a Constructor
2,507.72
5.28
call this is a line of code that is
2,510.64
5.56
going to construct a student object form
2,513
6.119
for me using synonyms it is going to
2,516.2
7
instantiate a student object for me and
2,519.119
6.041
again how is it going to create that
2,523.2
3.56
object it's going to use the student
2,525.16
4.32
class as a template as a mold of sorts
2,526.76
5.04
so that every student is structured the
2,529.48
3.96
same every student is going to have a
2,531.8
2.96
name every student's going to have a
2,533.44
4.36
house but because I can pass in
2,534.76
5
arguments to this student function
2,537.8
4.68
capital S I'm going to be able to
2,539.76
7.04
customize the contents of that object so
2,542.48
5.76
if you think about the real world if
2,546.8
3
you've ever been on a street or a
2,548.24
3.44
neighborhood where all of the houses
2,549.8
4.799
kind of look the same but they're might
2,551.68
4.52
be painted differently they might be
2,554.599
2.96
decorated a little bit differently on
2,556.2
3.28
the outside all of those houses might
2,557.559
3.681
have been built using the exact same
2,559.48
4.68
blueprint sort of a mold if you will but
2,561.24
4.92
then you can specialize exactly the
2,564.16
4.36
finer points of those houses by painting
2,566.16
3.6
the outside a different color or
2,568.52
3.12
planting different trees you can style
2,569.76
4.799
them differently similar uh in spirit
2,571.64
5.16
here we have a student
2,574.559
4.361
blueprint that's always going to have
2,576.8
4.2
now a name and a house but it's up to
2,578.92
4
you and me to pass in any name in any
2,581
4.24
house that we want now where is this
2,582.92
4
function the fact that I'm calling
2,585.24
3.76
student capital S and then a parenthesis
2,586.92
3.88
and a Clos parenthesis with arguments
2,589
3.48
inside suggests that there's a function
2,590.8
3.6
somewhere in the world that has been
2,592.48
4.24
defined with de that's going to be
2,594.4
4.64
called well as you might have guessed by
2,596.72
4.839
now the function that will always be
2,599.04
5.279
called by definition of how python
2,601.559
5.961
classes work is a fun called double
2,604.319
6.081
underscore in it double underscore why
2,607.52
4.76
it's a crazy name but it's what the
2,610.4
4.199
authors of python chose to just
2,612.28
3.799
implement the
2,614.599
4.361
initialization of an object in Python
2,616.079
5.201
now the only weird thing especially
2,618.96
4.32
weird thing I will admit is this it
2,621.28
4.92
would be way clearer to me too if the
2,623.28
5.96
only two parameters for in it were just
2,626.2
4.84
name comma house right that's how we've
2,629.24
3.8
defined every function thus far in the
2,631.04
4.4
class you just specify the parameters
2,633.04
4.519
that you want the function to accept and
2,635.44
3.76
indeed that lines up with what I'm doing
2,637.559
4.401
on line 15 I am only passing in two
2,639.2
6.32
things to the student function but it
2,641.96
5.879
turns out that the authors of python
2,645.52
3.76
need to give us a little bit of help
2,647.839
3.641
here because suppose that you pass in
2,649.28
5.559
name and house to this init method and a
2,651.48
5.48
method is just a function inside of a
2,654.839
4.201
class what are you going to do with the
2,656.96
4.159