text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
really just enables python to | 5,469.48 | 3.84 |
automatically detect when you're trying | 5,471.6 | 4.8 |
to manually set a value the equal sign | 5,473.32 | 5.2 |
and the dot as I've highlighted here is | 5,476.4 | 3.68 |
enough of a clue to python to realize | 5,478.52 | 2.719 |
wait a minute you're trying to set a | 5,480.08 | 3.559 |
value let me see if this class has a | 5,481.239 | 4.44 |
Setter defined and if so I'm going to | 5,483.639 | 3.281 |
call that and I'm not just going to | 5,485.679 | 3.721 |
blindly assign the value from right to | 5,486.92 | 5.56 |
left so it's just giving me more control | 5,489.4 | 5.92 |
other questions on properties when we | 5,492.48 | 6.96 |
use a gets we use have just one argument | 5,495.32 | 6.72 |
and if we use Setters it's always going | 5,499.44 | 5.199 |
to be two arguments is that normal | 5,502.04 | 4.24 |
correct it's always going to be one | 5,504.639 | 4.361 |
argument self for the getter two | 5,506.28 | 5.08 |
arguments for the setter self and | 5,509 | 4.679 |
something else and the intuition for | 5,511.36 | 4 |
that is if you're getting a value you | 5,513.679 | 3.281 |
don't need to pass anything else in | 5,515.36 | 3.52 |
because you already know the object it's | 5,516.96 | 3.48 |
called student in this case so you're | 5,518.88 | 3.04 |
just going to get the value of that | 5,520.44 | 3.719 |
property but if you want to set the | 5,521.92 | 3.88 |
property to something else you got to | 5,524.159 | 3.761 |
pass in that argument you've got to pass | 5,525.8 | 3.68 |
in the value to which you want to set it | 5,527.92 | 4.279 |
so it's always zero or one however you | 5,529.48 | 6.28 |
see it as one or two because again any | 5,532.199 | 6.641 |
function inside of a class AKA a method | 5,535.76 | 5.2 |
is going to be automatically passed self | 5,538.84 | 4.44 |
so that you have access to that current | 5,540.96 | 4.759 |
object in memory how about one other | 5,543.28 | 6.12 |
question on properties why didn't we use | 5,545.719 | 6.601 |
the same underscore house in init meod a | 5,549.4 | 4.719 |
good question so even though I'm using | 5,552.32 | 4.28 |
the underscore house here in my Setter | 5,554.119 | 4.201 |
and the underscore house here in my | 5,556.6 | 4.559 |
getter I deliberately did not use it up | 5,558.32 | 5.64 |
here the reason for that is that by | 5,561.159 | 6.161 |
using self. house and this equal sign | 5,563.96 | 5.08 |
that's the same pattern that I want | 5,567.32 | 3.879 |
python to recognize I want python to | 5,569.04 | 4.24 |
automat aut atically call the setter | 5,571.199 | 4.361 |
even when I'm passing in the house via | 5,573.28 | 4.879 |
the init method if I were to change this | 5,575.56 | 5.159 |
to do this that would circumvent the | 5,578.159 | 5 |
setter and now there's no error checking | 5,580.719 | 5.161 |
in in it whatsoever so it's such a fine | 5,583.159 | 4.841 |
line the only thing standing between us | 5,585.88 | 4.04 |
and error checking or no error checking | 5,588 | 3.8 |
is the presence or absence of this | 5,589.92 | 3.92 |
underscore but that's typically the | 5,591.8 | 4.359 |
convention by not using the underscore | 5,593.84 | 4.12 |
there make sure that even that | 5,596.159 | 3.681 |
assignment goes through the setter so | 5,597.96 | 3.719 |
that honestly I don't have to copy paste | 5,599.84 | 3.64 |
the same error checking in two places I | 5,601.679 | 3.841 |
can put it just in the setter so it's | 5,603.48 | 4.239 |
better design and that's why I manually | 5,605.52 | 3.84 |
retyped it at first but then I deleted | 5,607.719 | 4.361 |
it from in it well allow me to propose | 5,609.36 | 4.56 |
that we make one other change to this | 5,612.08 | 4.48 |
file might as well go ahead and Define a | 5,613.92 | 5.08 |
property for name as well and let me go | 5,616.56 | 4.28 |
ahead and do this maybe above the house | 5,619 | 4 |
property just to keep things uh in the | 5,620.84 | 4.24 |
same order as I defined them earlier let | 5,623 | 4.48 |
me give myself another property this | 5,625.08 | 4.159 |
one's going to be called name it's going | 5,627.48 | 3.48 |
to take one argument called self as | 5,629.239 | 3.681 |
always and this one very similarly is | 5,630.96 | 4.719 |
just going to return self doore name so | 5,632.92 | 4.199 |
I'm going to anticipate that I'm going | 5,635.679 | 4.04 |
to have to rename name also so that I | 5,637.119 | 4.761 |
don't have that same Collision as before | 5,639.719 | 3.881 |
but now let me go ahead and Define | 5,641.88 | 4.839 |
another uh setter this one for name so | 5,643.6 | 6.039 |
the convention is at name. Setter why | 5,646.719 | 5.96 |
name because the property I just created | 5,649.639 | 5.48 |
is called name so the getter and Setter | 5,652.679 | 4.52 |
sort of work in conjunction in that in | 5,655.119 | 4.52 |
this way if you will let me go down | 5,657.199 | 4.601 |
under atame Setter and Define a another | 5,659.639 | 4.201 |
function also called name but the key | 5,661.8 | 3.72 |
thing here is that it's not identical | 5,663.84 | 3.92 |
it's not the exact same function name | 5,665.52 | 4.48 |
and the exact same number of arguments | 5,667.76 | 4.68 |
the setter again takes a second argument | 5,670 | 3.84 |
and I can call it anything I want but | 5,672.44 | 2.759 |
I'm going to call it name because that's | 5,673.84 | 3.359 |
what's being passed in and I'm going to | 5,675.199 | 4.361 |
air put my error checking here if not | 5,677.199 | 4.641 |
name just like we used to do let's go | 5,679.56 | 4.32 |
ahead and raise a value error and let's | 5,681.84 | 4.399 |
put an explanatory message like uh | 5,683.88 | 5.52 |
Missing name quote unquote otherwise | 5,686.239 | 6.681 |
let's go ahead and update self doore | 5,689.4 | 6.799 |
name to equal name and I don't have to | 5,692.92 | 5.92 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.