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