Python for Absolute Beginners Transcripts
Chapter: Reading and writing files in Python
Lecture: Demo: Writing lines in a text file
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
Let me pull back the covers just a little bit and have you have a look inside of how you're watching this course right now.
0:08
There's 10, 12 servers throughout the world that deliver video to you and the site uses geolocation to figure out which video server is closest to you
0:17
and then it will route that over based on your IP address. So, one thing that's important for us to do is to make sure
0:22
that our files, the video files, are always consistent. We edit one, that it's edited in all 10 places, not just one
0:30
or two or five places, it can get really confusing. So we have this software that will go around and around
0:36
and it will check one location where we drop our files and then will automatically verify that every other location
0:42
in the world, Brazil, Tokyo, Sydney, Frankfurt or wherever has exactly that same file, same size, whatever.
0:48
Now, if it's different, it's going to download it from the source place and distribute it around here as you can see in this example here.
0:54
How do I know that this is working? How do I know that this has happened or is happening now? It's because that application, it logs to a file
1:03
a text file, and it appends line after line after line as it's doing its work and on Unix, Linux macOS
1:10
you can run this thing called tail and what it will do is basically just show you the outputs of a file at the end.
1:16
They show me here, they say, tail -n 1000 -f and give it the file name, that means show me 1000 historical lines and then anything that's new
1:24
update the screen with it. So, we're going to add this type of functionality to our rock, paper, scissors app. Now, of course it's not as important
1:32
because you're interacting with it. This is really important because there's no visual aspect to this at all, the only way without logging
1:39
I would know what's happening, is to just go to those file locations and verify, yup looks like the files are getting copied here.
1:46
That's not good enough, you want to have some kind of output and see it as the time and how important the message is
1:52
and what the message is associated with that, its source all sorts of cool stuff that we're going to be able to add to our program here in a minute.