text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
operator Plus in between that is to say
9,632.68
5.44
if I go back to VSS code here what I'm
9,636.16
5.119
trying to do is Implement support for
9,638.12
5.56
this well let me try without writing any
9,641.279
5.241
other code just yet python a vault up
9,643.68
6.12
high enter type error unsupported
9,646.52
7.12
operand types for Vault and Vault that
9,649.8
6.2
is to say python at this moment does not
9,653.64
4.52
know what it means to add two vaults
9,656
3.8
together right you and I might have an
9,658.16
3.319
instinct probably want to combine the
9,659.8
4.08
gallions and the sickles and the canuts
9,661.479
4.401
respectively python doesn't know that it
9,663.88
3.399
just knows that you have a new class
9,665.88
3.479
called Vault but let's teach python to
9,667.279
4.721
do this let me clear my terminal window
9,669.359
4.161
let me scroll back up to the class
9,672
3.88
itself where at the moment I only have
9,673.52
4.919
two special methods in it and stir but
9,675.88
4.76
let's add this third all right let me go
9,678.439
3.721
into the class here and Define
9,680.64
3.44
underscore uncore add underscore
9,682.16
4.319
underscore and then specify its first
9,684.08
4.96
parameter as self as before and then a
9,686.479
4.161
second parameter for this particular
9,689.04
4
method called by convention other now as
9,690.64
3.719
always I could name those parameters
9,693.04
2.439
anything I want but I'm going to stick
9,694.359
3.401
with convention Here and Now inside of
9,695.479
4.241
this method am I going to have to now
9,697.76
4.48
add together the contents of two vaults
9,699.72
4.04
well what two vaults well if we scroll
9,702.24
3.4
down to our goal at hand the goal goal
9,703.76
3.639
of course is to add this Vault plus this
9,705.64
3.6
other Vault Potter plus Weasley
9,707.399
4.321
respectively well it turns out in Python
9,709.24
4.32
that when you do overload an operator
9,711.72
3.52
like Plus what's going to happen
9,713.56
3.719
automatically as soon as python sees
9,715.24
3.4
that is it's going to call that
9,717.279
3.16
underscore underscore ad underscore
9,718.64
3.799
uncore method and it's going to pass
9,720.439
4.121
into it two arguments whatever the
9,722.439
4.481
operand is on the left Potter in this
9,724.56
4.48
case and whatever the operand is on the
9,726.92
4.32
right Weasley in this case and those
9,729.04
3.96
values are going to get passed in as
9,731.24
4.56
self and other respectively what that
9,733
4.24
means is that we can access their
9,735.8
3.2
contents up here in our implementation
9,737.24
3.6
of AD as follows let me go ahead and
9,739
4.24
Define a local variable called gallions
9,740.84
4.36
and set that equal to for instance the
9,743.24
5.159
sum of self dot gallions whatever's in
9,745.2
5.4
uh Potter's vault in this case plus
9,748.399
4.08
whatever is in Weasley's vault in this
9,750.6
4.36
case which would be other. gallions let
9,752.479
5.761
me do the same for sickles self. sickles
9,754.96
6
plus other Doles and let me lastly do
9,758.24
6.079
that for canuts so self. canuts Plus
9,760.96
4.96
other. canuts
9,764.319
2.96
but at the end of the day I'm going to
9,765.92
3.72
need to return a brand new bigger Vault
9,767.279
4.281
that contains all of those contents
9,769.64
3.92
together and if we ultimately want to
9,771.56
4.4
assign that bigger Vault to a variable
9,773.56
4.719
like total here on the left we better
9,775.96
4.399
indeed return a value from this ad
9,778.279
3.761
method so I'm going to go ahead and give
9,780.359
4.401
myself a brand new vault as by returning
9,782.04
4.359
Capital vault which of course is going
9,784.76
4.04
to call My Vault function into which I
9,786.399
3.96
can now pass some of those
9,788.8
3.44
initialization arguments well how many
9,790.359
3.401
gallion sickles and canuts do I want
9,792.24
3.72
this brand new Vault to contain well I
9,793.76
4.719
want it to contain this many gallions
9,795.96
5.319
this many sickles and this many canuts
9,798.479
4.361
so ultimately what we're doing in this
9,801.279
3.921
implementation of ad is adding together
9,802.84
4.76
those gallion sickles and canuts passing
9,805.2
4
them to the Vault function so that we
9,807.6
4
get a brand new bigger Vault and return
9,809.2
5.56
that Al together so now I've defined
9,811.6
5.52
this new special method called add that
9,814.76
6.04
should now just make Plus work for two
9,817.12
6
vaults all right let's see let me run
9,820.8
4.12
down to my terminal window python a
9,823.12
5.159
vault high and hit enter and voila now
9,824.92
6.439
we've implemented an overloaded operator
9,828.279
5.2
plus to do what you and I as humans
9,831.359
3.601
would hope would be the case when you
9,833.479
3.521
add two vaults together but I've now
9,834.96
4.12
written the code more specifically to
9,837
5.6
teach python what it means concretely to
9,839.08
5.92
add two vaults together and it's with
9,842.6
4.28
very similar code in effect underneath
9,845
3.72
the hood that python is doing this for
9,846.88
3.96
two strings to concatenate them together
9,848.72
4.32
to joining two lists into a new list
9,850.84
4.96