text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
access those instance variables using | 4,718.48 | 3.88 |
this familiar dot notation that's how we | 4,720.52 | 3.679 |
began the story of classes just setting | 4,722.36 | 3.839 |
these attributes ourselves but you can | 4,724.199 | 4.241 |
also read these attributes themselves | 4,726.199 | 4.841 |
and change them later if you want and | 4,728.44 | 5.719 |
this will effectively circumvent the if | 4,731.04 | 4.72 |
condition and the other if condition in | 4,734.159 | 4.201 |
our init method because that is only | 4,735.76 | 5.6 |
called when you first create the student | 4,738.36 | 5.12 |
object there's nothing stopping me at | 4,741.36 | 5.24 |
the moment from just changing the house | 4,743.48 | 6.4 |
or the name after so if I now clear my | 4,746.6 | 4.88 |
terminal window and run python of | 4,749.88 | 4.12 |
studenty I'll still type in Harry and | 4,751.48 | 4.679 |
Gryffindor to meet my requirements that | 4,754 | 4.08 |
the house be one of those four but when | 4,756.159 | 3.961 |
it's printed notice I've still | 4,758.08 | 4.92 |
overridden it so it seems that while | 4,760.12 | 4.64 |
classes do allow us a little more | 4,763 | 4.28 |
control over the data we're storing it | 4,764.76 | 5.32 |
doesn't necessarily prevent the user be | 4,767.28 | 5.12 |
it or rather the programmer be it myself | 4,770.08 | 4.32 |
or maybe a colleague from still kind of | 4,772.4 | 4.799 |
messing things up so here too in the | 4,774.4 | 4.56 |
spirit of programming a little more | 4,777.199 | 3.801 |
defensively allow me to introduce | 4,778.96 | 6.16 |
another feature of python as well namely | 4,781 | 7.32 |
properties so a property is really just | 4,785.12 | 5.92 |
an attribute that has even more defense | 4,788.32 | 4.56 |
mechanisms put into place a little | 4,791.04 | 4.32 |
little more functionality implemented by | 4,792.88 | 5.359 |
you to prevent programmers like me and | 4,795.36 | 4.92 |
you from messing things up like these | 4,798.239 | 4.161 |
attributes so again a property is going | 4,800.28 | 3.919 |
to be an attribute that you and I just | 4,802.4 | 4.72 |
have more control over how we just write | 4,804.199 | 4.761 |
a little more code using some python | 4,807.12 | 3.76 |
conventions and how we're going to do | 4,808.96 | 4.679 |
that is going to use in just a moment a | 4,810.88 | 5.64 |
feature a keyword known as app property | 4,813.639 | 4.761 |
which is technically a function property | 4,816.52 | 3.76 |
is a function in Python but we're about | 4,818.4 | 4.799 |
to see some new at syntax that allows | 4,820.28 | 4.8 |
you to decorate functions and this too | 4,823.199 | 4.081 |
is a term of Art in the world of python | 4,825.08 | 4.48 |
you can have decorators which are | 4,827.28 | 4.72 |
functions that modify the behavior of | 4,829.56 | 4.28 |
other functions if you will and we'll | 4,832 | 3.84 |
leave it at that without going too much | 4,833.84 | 3.76 |
into the weeds and we'll see by example | 4,835.84 | 3.319 |
how you can use these decorator | 4,837.6 | 4 |
specifically to define properties so let | 4,839.159 | 5.04 |
me go back to vs code here and let me | 4,841.6 | 5.76 |
propose that I do this I'm going to go | 4,844.199 | 7.96 |
ahead and create how about a property | 4,847.36 | 9.16 |
called how house as follows inside of my | 4,852.159 | 7.04 |
uh student class I'm going to go ahead | 4,856.52 | 4.6 |
and below my init method and below my | 4,859.199 | 4.081 |
stir method I'm going to go ahead and | 4,861.12 | 5.039 |
Define a function called house that | 4,863.28 | 5.16 |
takes as it always must one argument at | 4,866.159 | 4.56 |
least called self and what I'm going to | 4,868.44 | 7.239 |
do now is return uh self. house so I'm | 4,870.719 | 6.761 |
just going to define a method called | 4,875.679 | 4.801 |
House whose sole purpose in life is to | 4,877.48 | 5.88 |
return the value of house | 4,880.48 | 4.96 |
but I'm going to Define one other method | 4,883.36 | 4.319 |
curiously also called house but that's | 4,885.44 | 5.32 |
going to take into as arguments two | 4,887.679 | 6.641 |
value self as always and also a value | 4,890.76 | 6.12 |
called house and I'm going to now do | 4,894.32 | 6.04 |
this uh I'm going to say self rather I'm | 4,896.88 | 7.319 |
going to do self. house equals house now | 4,900.36 | 5.24 |
what have I done well let me just | 4,904.199 | 3.601 |
temporarily add some comments here in a | 4,905.6 | 3.8 |
moment we're going to start referring to | 4,907.8 | 4.04 |
this generally as a getter and down here | 4,909.4 | 3.88 |
I'm going to refer to to this as a | 4,911.84 | 3.24 |
Setter and this is terminology you | 4,913.28 | 3.399 |
frequently see in the world of java if | 4,915.08 | 3 |
some of you have programmed in Java | 4,916.679 | 4.201 |
before but as the names imply a getter | 4,918.08 | 6.24 |
is a function for a class that gets some | 4,920.88 | 6.96 |
attribute a Setter is a function in some | 4,924.32 | 6.6 |
class that sets some value and now even | 4,927.84 | 4.76 |
though we're not done and there's a bit | 4,930.92 | 3.52 |
of a mistake in the code I've already | 4,932.6 | 4 |
written intuitively what we're going to | 4,934.44 | 4.759 |
do is this we're trying to prevent | 4,936.6 | 4.68 |
programmers myself included from | 4,939.199 | 4.201 |
circumventing my error checking that I | 4,941.28 | 4.68 |
put into place for name and house how | 4,943.4 | 4.279 |
can I do that well we don't have that | 4,945.96 | 3.6 |
many building blocks in programming we | 4,947.679 | 3.921 |
have things like variables for data and | 4,949.56 | 4.24 |
we have functions for actions well why | 4,951.6 | 5.039 |
don't we do this why don't we somehow | 4,953.8 | 5.439 |
require that in order to access an | 4,956.639 | 4.801 |
attribute you go through some function | 4,959.239 | 4.361 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.