text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
name in the house like literally where | 2,659.04 | 4.039 |
are you going to put them if you want to | 2,661.119 | 4.921 |
remember the name in the house for this | 2,663.079 | 4.601 |
student you've got to be able to store | 2,666.04 | 3.84 |
those values somewhere and how do you | 2,667.68 | 4.8 |
store them in the current object that | 2,669.88 | 4.12 |
has just been | 2,672.48 | 3.96 |
instantiated well the authors of python | 2,674 | 3.839 |
decided that the convention is going to | 2,676.44 | 4.28 |
be that this init method also semi | 2,677.839 | 5.681 |
secretly takes a third argument that has | 2,680.72 | 5.119 |
to come first by convention it's called | 2,683.52 | 3.72 |
self but you could call it technically | 2,685.839 | 2.841 |
anything you want but the convention is | 2,687.24 | 4.24 |
to always call it self and self as its | 2,688.68 | 5.28 |
name implies gives you access to the | 2,691.48 | 4.48 |
current object that was just created | 2,693.96 | 5.04 |
created what does that mean again now on | 2,695.96 | 5.2 |
line 14 now that it's moved down a | 2,699 | 4.319 |
little bit this line here is a | 2,701.16 | 4.52 |
Constructor it constructs a student | 2,703.319 | 4.04 |
object but there's nothing in that | 2,705.68 | 3.439 |
object initially there's no name there's | 2,707.359 | 4.2 |
no house but the object exists in the | 2,709.119 | 4.801 |
computer's memory it's up to now you to | 2,711.559 | 4.401 |
store the name and the house inside of | 2,713.92 | 3.8 |
that object how do you do that well | 2,715.96 | 4.119 |
python will just automatically call this | 2,717.72 | 4.359 |
init method for you and it's going to | 2,720.079 | 6.081 |
automatically pass in a reference to a | 2,722.079 | 6.921 |
an argument that represents the current | 2,726.16 | 5.04 |
object that it just constructed in | 2,729 | 4.319 |
memory for you and it's up to you to | 2,731.2 | 4.08 |
populate it with values and what this | 2,733.319 | 4.321 |
means is that inside of your init method | 2,735.28 | 5.039 |
you can literally do self. name to | 2,737.64 | 5.919 |
create a new attribute AKA an instance | 2,740.319 | 5.841 |
variable inside of that otherwise empty | 2,743.559 | 4.961 |
object and put this name inside of it it | 2,746.16 | 4.8 |
allows you to do self. house and store | 2,748.52 | 4.36 |
that value of house now you could call | 2,750.96 | 3.08 |
these things anything you want they | 2,752.88 | 3.04 |
could be n they could be H as before | 2,754.04 | 5.36 |
four but that's really not very self uh | 2,755.92 | 5.639 |
explanatory much better to do this kind | 2,759.4 | 4.919 |
of convention self. name equals name | 2,761.559 | 5.241 |
self. house equals house and this is | 2,764.319 | 5.52 |
like installing into the otherwise empty | 2,766.8 | 5.92 |
object the value name and house and | 2,769.839 | 5.641 |
storing them in really identically named | 2,772.72 | 5.04 |
instance variables in the object and | 2,775.48 | 4.359 |
again an object is just an instance of a | 2,777.76 | 4.4 |
class now I know that was a lot of | 2,779.839 | 4.801 |
vocabulary that's a lot of weird syntax | 2,782.16 | 5.52 |
so any questions on this init method | 2,784.64 | 4.56 |
whose purpose in life again is to | 2,787.68 | 4.439 |
initialize an otherwise empty object | 2,789.2 | 4.84 |
when you first create it so what is the | 2,792.119 | 4.121 |
difference between the init method and | 2,794.04 | 5.079 |
default Constructor a good question so | 2,796.24 | 4.839 |
in other languages if you programmed | 2,799.119 | 4.48 |
before for instance Java there are | 2,801.079 | 4.201 |
functions that are explicitly called | 2,803.599 | 3.881 |
Constructors that indeed construct an | 2,805.28 | 4.319 |
object they initialize it with values | 2,807.48 | 3.92 |
python technically calls this init | 2,809.599 | 3.841 |
method the initialization method it | 2,811.4 | 5.4 |
initializes the value it's online 14 uh | 2,813.44 | 5.72 |
line 15 now of my code if I scroll back | 2,816.8 | 4.72 |
down that I'm technically constructing | 2,819.16 | 5 |
the object it turns out there's another | 2,821.52 | 4.2 |
special method in Python that we won't | 2,824.16 | 3.6 |
talk about in detail today called | 2,825.72 | 4.599 |
underscore uncore new underscore | 2,827.76 | 4.559 |
underscore that actually handles the | 2,830.319 | 4.04 |
process of creating an empty object in | 2,832.319 | 4.721 |
memory for us but generally speaking you | 2,834.359 | 4.641 |
the programmer don't need to manipulate | 2,837.04 | 4 |
the new function it just works for you | 2,839 | 4.319 |
instead you define your own init method | 2,841.04 | 4.279 |
here an init function inside of your | 2,843.319 | 4.881 |
class and that method initializes the | 2,845.319 | 5.161 |
contents of the object so there's | 2,848.2 | 3.48 |
technically a distinction between | 2,850.48 | 3.04 |
constructing the object with new and | 2,851.68 | 3.84 |
initializing it with in it but in the | 2,853.52 | 3.76 |
world of python you pretty much only | 2,855.52 | 4.48 |
worry about the in it method python | 2,857.28 | 5.12 |
generally does the other part for you a | 2,860 | 4.8 |
good question others uh what about if | 2,862.4 | 5.439 |
you want to store more than one name or | 2,864.8 | 4.96 |
more than one house a good question if | 2,867.839 | 3.881 |
you want to store more than one name or | 2,869.76 | 3.4 |
more than one house you can do this in | 2,871.72 | 3.359 |
different ways you could create other | 2,873.16 | 4.159 |
attributes technically called instance | 2,875.079 | 6.161 |
variables like self. name one self. name | 2,877.319 | 5.961 |
two but we've seen in the past that that | 2,881.24 | 3.72 |
is not a very good design just to have | 2,883.28 | 3.4 |
multiple variables to store multiple | 2,884.96 | 3.8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.