text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
complicated code this line here on line | 8,046.119 | 5.08 |
13 just means create an object of the | 8,048.639 | 4.04 |
current class what class is that well | 8,051.199 | 3.52 |
whatever CLS is well that by definition | 8,052.679 | 4.04 |
of how it all works is going to be | 8,054.719 | 4.36 |
student and I want you to initialize it | 8,056.719 | 6.48 |
as always with name and house so now | 8,059.079 | 7 |
scrolling down my code is this and this | 8,063.199 | 5.241 |
is just nice to read you did perhaps | 8,066.079 | 4.441 |
have to acquire a taste for this and I | 8,068.44 | 3.719 |
sound a little odd saying this is nice | 8,070.52 | 4.159 |
to read but indeed student doget just | 8,072.159 | 4.201 |
tells me what's going on I'm going to | 8,074.679 | 3.56 |
get a student I don't need a separate | 8,076.36 | 3.44 |
function written by me called get | 8,078.239 | 4 |
student in the file itself the get | 8,079.8 | 4.96 |
functionality is built into the class | 8,082.239 | 4.32 |
all my student related code now is | 8,084.76 | 3.56 |
together so let me go down to my | 8,086.559 | 3.201 |
terminal window and run python of | 8,088.32 | 3.919 |
student. enter let's type in Harry let's | 8,089.76 | 4.28 |
type in Gryffindor and we're back to | 8,092.239 | 4.84 |
where we began but but but everything | 8,094.04 | 5.84 |
related to students now is in this here | 8,097.079 | 5.201 |
class the only other thing in the file | 8,099.88 | 4.759 |
is Main and this conditional that we | 8,102.28 | 4.24 |
always use to avoid accidentally | 8,104.639 | 3.761 |
executing main when we're making a | 8,106.52 | 4.8 |
module or a package or the like so again | 8,108.4 | 6.199 |
a solution to a problem not a big one in | 8,111.32 | 5 |
the case of a relatively small program | 8,114.599 | 3.281 |
but one that you will eventually | 8,116.32 | 3.2 |
counters your programs get longer and | 8,117.88 | 5.279 |
longer with more and more entities to | 8,119.52 | 7.76 |
represent questions now on this use of a | 8,123.159 | 6.681 |
class method does the does the class | 8,127.28 | 4.52 |
have to be defined before the main | 8,129.84 | 4.279 |
function in terms of the order of the of | 8,131.8 | 4.16 |
the program a really good question so | 8,134.119 | 3.281 |
when in doubt let's try this so let's | 8,135.96 | 3.08 |
try to change the order let's move main | 8,137.4 | 3.799 |
to the top which I've often encouraged | 8,139.04 | 4.559 |
so let's go ahead and above the class do | 8,141.199 | 4.721 |
this and notice now that technically | 8,143.599 | 5 |
line two is mentioning student which | 8,145.92 | 5.44 |
does not exist until line six and Below | 8,148.599 | 4.04 |
let me go ahead and clear my terminal | 8,151.36 | 4.04 |
and run python of student. so far so | 8,152.639 | 6.321 |
good Harry Gryffindor okay uh and indeed | 8,155.4 | 5.799 |
Harry's from Gryffindor the reason | 8,158.96 | 4.48 |
Michael it does not matter in this case | 8,161.199 | 4.04 |
is because we're not actually calling | 8,163.44 | 4.199 |
Maine until the very end and just as in | 8,165.239 | 4.041 |
the past that means that python has a | 8,167.639 | 3.121 |
chance to read everything top to bottom | 8,169.28 | 3.959 |
left to right so everything exists I | 8,170.76 | 5.2 |
would say generally classes are defined | 8,173.239 | 5.041 |
at the top of the file however it would | 8,175.96 | 4.8 |
be even maybe cleaner to move the | 8,178.28 | 4.879 |
class's definition to its own file and | 8,180.76 | 4.6 |
then import it so essentially to make | 8,183.159 | 4.281 |
reusable code by putting it into your | 8,185.36 | 3.879 |
own module or package so that not just | 8,187.44 | 3.96 |
this program but many others can use | 8,189.239 | 4.48 |
that definition of student as well other | 8,191.4 | 5.319 |
questions now on classes class methods | 8,193.719 | 5.201 |
or the like I wanted to ask is there a | 8,196.719 | 6.96 |
way to um like declare all the all the | 8,198.92 | 7.92 |
possible all the possible attributes of | 8,203.679 | 4.521 |
the class because | 8,206.84 | 5.12 |
it looks so inconsistent um well so my | 8,208.2 | 5.6 |
takeaway there is this is Python's | 8,211.96 | 3.399 |
approach to these principles different | 8,213.8 | 3.08 |
languages like Java just take a | 8,215.359 | 3.32 |
different approach but have very similar | 8,216.88 | 4.36 |
features the syntax just tends to vary | 8,218.679 | 4.441 |
and this is how the python Community | 8,221.24 | 4.399 |
chose to implement this idea the right | 8,223.12 | 4.359 |
mental model ultimately is that these | 8,225.639 | 4.601 |
instance variables instant methods | 8,227.479 | 7.281 |
belong to or operate on specific objects | 8,230.24 | 8.04 |
a specific student a specific hat class | 8,234.76 | 6.24 |
variables and class methods operate on | 8,238.28 | 6.359 |
the entire class itself or in turn all | 8,241 | 5.16 |
objects of that class which we've not | 8,244.639 | 3.641 |
seen them a demonstration of but it's | 8,246.16 | 4.08 |
sort of a higher level concept so it | 8,248.28 | 4.119 |
turns out besides these class methods | 8,250.24 | 4.079 |
which are distinct from those instance | 8,252.399 | 3.681 |
methods which to be fair do not have | 8,254.319 | 3.761 |
their own decorator they just are by | 8,256.08 | 3.68 |
default instance method there's yet | 8,258.08 | 3.16 |
other types of methods you can have in | 8,259.76 | 3.36 |
classes in Python they tend to be called | 8,261.24 | 3.92 |
Static methods and they too come with | 8,263.12 | 3.8 |
another decorator called at static | 8,265.16 | 3.479 |
method which which is a rabbit hole we | 8,266.92 | 3.92 |
won't go down but realize that there is | 8,268.639 | 3.92 |
yet other functionality that you can | 8,270.84 | 3.12 |
leverage within object-oriented | 8,272.559 | 3.401 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.