text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
method which is amazing because now I
5,218.48
5.639
can keep all of my error checking in one
5,221.28
5.879
place in the setter and it will now get
5,224.119
5.52
called either when I create the object
5,227.159
5.441
for the first time because of in it or
5,229.639
5.241
even if the you the programmer tries to
5,232.6
5.24
circumvent that init method and change
5,234.88
4.88
the value of this attribute my Setter
5,237.84
4.48
will also get called my Setter will get
5,239.76
6.359
called anytime I access. house but
5,242.32
6.76
there's one fix I need to make
5,246.119
7
unfortunately I have collided names
5,249.08
7.36
right now if we go up here on line five
5,253.119
5.56
this is an instance variable it's a
5,256.44
4.64
string inside of myself inside of the
5,258.679
4.601
current student object called name and
5,261.08
5
this is another instance variable called
5,263.28
5.32
House unfortunately if I have an
5,266.08
5.28
instance variable called name and house
5,268.6
5.48
I cannot also have functions called
5,271.36
4.72
house they're going to collide you got
5,274.08
4.24
to decide do you want the variable to be
5,276.08
4.48
called house or do you want the function
5,278.32
4.2
to be called House unfortunately you
5,280.56
3.559
can't have both because now Python's
5,282.52
3.679
going to confuse one for the other so
5,284.119
4.481
the conventional fix for this is to do
5,286.199
6.281
this to have the setter not store the
5,288.6
6.599
value that's passed in in self. house
5,292.48
4.84
but to use an almost identical name but
5,295.199
4.201
to use a little indicator that you means
5,297.32
4.04
you know you're doing this correctly you
5,299.4
4.16
typically by invention put an underscore
5,301.36
5.72
in front of the instance variable's name
5,303.56
5.2
and when you return it up here you
5,307.08
4.96
similarly put an underscore so now
5,308.76
5.64
technically my instance variable is
5,312.04
6.84
called underscore house but my property
5,314.4
7.239
which is a fancier attribute if you will
5,318.88
6.6
is called house alone huge amount of
5,321.639
6.361
syntax I know but it's a very powerful
5,325.48
4.719
feature and again this is why you can
5,328
4.4
graduate from dictionaries alone and
5,330.199
4.361
have so much more functionality at your
5,332.4
4
disposal let me go ahead and clear my
5,334.56
3.32
terminal window and run python of
5,336.4
4.6
student. enter name all right let's go
5,337.88
5.279
ahead and type in Harry let's go ahead
5,341
4.159
and type in Gryffindor crossing my
5,343.159
5.321
fingers as always and now look invalid
5,345.159
5.921
house this is a good thing why because
5,348.48
6.159
notice in my main function I'm still
5,351.08
6.76
trying maliciously if you will to change
5,354.639
5.6
Harry's house to not be one of the four
5,357.84
3.799
valid ones I'm trying to change it to
5,360.239
3.4
his childhood home of number four
5,361.639
4.681
private drive but because python knows
5,363.639
4.641
that wait a minute you're trying to
5,366.32
5.12
assign that is set a value and that
5,368.28
6.08
value AKA house is now defined as a
5,371.44
4.56
property you're going to have to go
5,374.36
4.08
through the setter function instead to
5,376
5.199
even let you change that value and
5,378.44
5.799
because I have this rais value error if
5,381.199
5.48
the house is not as intended you're not
5,384.239
3.92
going to be allowed to change it to an
5,386.679
3.761
invalid value so I'm protecting the data
5,388.159
4.241
on the way in through the init method
5,390.44
4.56
and I'm even defending the data if you
5,392.4
4.839
try to override it there so I think the
5,395
4.28
only solution for me the programmer is
5,397.239
4.161
don't try to break my own code let me
5,399.28
3.68
remove that line because it's just not
5,401.4
3.6
going to work let me run python of
5,402.96
4.52
studenty and again type in Harry type in
5,405
4.84
griffindor enter and Harry is indeed
5,407.48
4.239
from Gryffindor if I did something
5,409.84
6.04
incorrect like Harry from number four
5,411.719
7.52
Private Drive enter we're again going to
5,415.88
5.52
see the value error because my code just
5,419.239
5
doesn't let that value in Via manual
5,421.4
7
input now or via that adversarial change
5,424.239
6.161
all right that was a lot but any
5,428.4
5.4
question on
5,430.4
5.839
properties uh while we are using gets
5,433.8
4.48
and Setters it's just for the purpose so
5,436.239
5.201
that we can find that um that function
5,438.28
6.16
that method that function in in our code
5,441.44
4.44
the reason that I'm going through the
5,444.44
2.84
trouble of defining this getter or
5,445.88
4.359
Setter is because I want to make sure
5,447.28
5.56
that programmers can not do things like
5,450.239
4.281
this if I'm going through the trouble of
5,452.84
4.64
validating the attributes for these
5,454.52
4.88
student objects I don't want you to be
5,457.48
3.639
able to go in there and just change them
5,459.4
4.44
at will I want to have some control over
5,461.119
4.161
that object so that you can just trust
5,463.84
2.96
that it's going to be correct as
5,465.28
4.2
designed so using a getter and Setter
5,466.8
4.8