text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
saying hello to Hermione to Harry to Ron
1,064.039
4.02
to Draco but there's these gaps now
1,065.96
4.579
between the lines
1,068.059
5.581
what's explains that symptom if if
1,070.539
5.02
nothing else it just looks ugly it
1,073.64
4.32
happens because in the text file we have
1,075.559
5.641
new line symbols uh in between those
1,077.96
6.3
names and the print always adds another
1,081.2
6.479
new line at the end so you you use the
1,084.26
5.94
same symbol twice perfect and here's a
1,087.679
4.38
good example of a bug a mistake in a
1,090.2
3.18
program but if you just think about
1,092.059
3.961
those first principles like how do each
1,093.38
4.799
of the lines of code work that I'm using
1,096.02
3.72
you should be able to reason exactly as
1,098.179
3.12
Rafal did there to say that all right
1,099.74
2.88
well one of those new lines is coming
1,101.299
3.601
from the file after each name and then
1,102.62
4.02
of course print all of these Weeks Later
1,104.9
3.96
is still giving us for free that extra
1,106.64
4.08
new line so there's a couple of possible
1,108.86
4.08
solutions I could certainly do this
1,110.72
4.079
which we've done in the past and pass in
1,112.94
3.66
a named argument to print like end
1,114.799
4.921
equals quote unquote and that's fine I
1,116.6
4.62
would argue a little better than that
1,119.72
3.42
might actually be to do this to strip
1,121.22
4.86
off of the end of the line the actual
1,123.14
4.919
new line itself so that print is
1,126.08
3.9
handling the printing of everything the
1,128.059
3.601
person's name game as well as the new
1,129.98
4.14
line but you're just stripping off what
1,131.66
4.379
is really just an implementation detail
1,134.12
4.38
in the file we chose to use new lines in
1,136.039
4.741
my text file to separate one name from
1,138.5
4.799
another so arguably it should be a
1,140.78
4.44
little cleaner in terms of design to
1,143.299
4.201
strip that off and then let print print
1,145.22
4.44
out what is really just now a name but
1,147.5
3.66
that's ultimately a design decision the
1,149.66
4.139
effect is going to be exactly the same
1,151.16
6.36
well if I'm going to open this file and
1,153.799
6.061
read all the lines and then iterate over
1,157.52
3.96
all of those lines and print them each
1,159.86
3.48
out I could actually combine this into
1,161.48
3.66
one thing because right now I'm doing
1,163.34
3.6
twice as much work I'm reading all of
1,165.14
4.38
the lines then I'm iterating over all of
1,166.94
4.92
the lines just to print out each of them
1,169.52
4.56
well in Python with files you can
1,171.86
3.78
actually do this I'm going to erase
1,174.08
3.9
almost all of these lines now keeping
1,175.64
4.919
only the with statement at top and
1,177.98
4.559
inside of this with statement I'm going
1,180.559
6.061
to say this for line in file go ahead
1,182.539
6.421
and print out quote unquote hello comma
1,186.62
4.98
and then line Dot R strip so I'm going
1,188.96
3.839
to take the approach of stripping off
1,191.6
3.42
the end of the line but notice how
1,192.799
5.101
elegant this is so to speak I've opened
1,195.02
5.039
the file in line one and if I want to
1,197.9
4.2
iterate over every line in the file I
1,200.059
4.141
don't have to very explicitly load all
1,202.1
4.319
read all the lines then iterate over all
1,204.2
3.719
of the lines I can combine this into one
1,206.419
3.901
thought it in Python you can simply say
1,207.919
4.681
for line and file and that's going to
1,210.32
3.719
have the effect of giving you a for Loop
1,212.6
3.42
that iterates over every line in the
1,214.039
3.901
file one at a time and on each iteration
1,216.02
4.38
updating the value of this variable line
1,217.94
6.359
to be Hermione then Harry then Ron then
1,220.4
6.12
Draco so this again is one of the
1,224.299
4.201
appealing aspects of python is that it
1,226.52
3.779
reads rather like English for line and
1,228.5
4.679
file print this it's a little more
1,230.299
5.581
compact when written this way well what
1,233.179
3.661
if though
1,235.88
2.94
I don't want quite this Behavior because
1,236.84
4.319
notice now if I run python of names.pi
1,238.82
4.739
it's correct I'm seeing each of the
1,241.159
4.26
names and each of the hellos and there's
1,243.559
5.1
no Extra Spaces in between but just to
1,245.419
5.64
be difficult I'd really like us to be
1,248.659
4.681
sorting these hellos really I'd like to
1,251.059
4.98
see Draco first then Harry then Hermione
1,253.34
4.5
then Ron no matter what order they
1,256.039
4.02
appear in the file so I could go in of
1,257.84
3.839
course to the file and manually change
1,260.059
3.12
the file but if that file is changing
1,261.679
3.601
over time based on who is typing their
1,263.179
3.661
name into the program that's not really
1,265.28
3.42
a good solution in code I should be able
1,266.84
3.54
to load the file no matter what it looks
1,268.7
4.8
like and just sort it all at once now
1,270.38
5.7
here is a reason to not do what I've
1,273.5
6.12
just done I can't iterate over each line
1,276.08
6.12
in the file and print it out but sort
1,279.62
4.86
everything in advance right logically if
1,282.2
4.32
I'm looking at each line one at a time
1,284.48
4.5