Python for Absolute Beginners Transcripts
Chapter: Reading and writing files in Python
Lecture: Practice exercises

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Well that's enough reading and writing files for me. It's time for you to read and write to some files yourself.
0:07 So you're going to do some similar things that we've done here, work with JSON files work with lines of texts and plain text files.
0:13 Let's go see what I got on deck for you. Over here in chapter nine working with files you've got the standard introduction
0:20 threw in a few concepts for you, determining the full path of a file using os.path, reading a file using with open file name r, write in to a file
0:30 make it a w, working with a JSON, import this loading from and writing to various files and finally, the exercises that you're going to do
0:40 are going to be going back to the games that we created. So, the Tic Tac Toe game from back in CH08 the one about problem solving at least
0:48 whatever number that turns out to be at the end of this course, and work with that. If you happen to have gotten all the way
0:53 through the previous chapters exercises and you did build Connect Four, that one's yours. Go ahead and use that instead.
1:00 The idea, we'll work with either of them. What we are going to do is just create a leaderboard. Use JSON format if you like.
1:06 That works out really easy so that's what we did. So a leaderboard, create that, and update it as you win and play. Then add a running log file.
1:13 This can just be appending to a text file nothing about it fancy, logging frameworks and just do that.
1:18 That will help you practice appending to text files. That'll be great. If you want to, and you get to the end
1:24 and you want to try it out, you could use Logbook. It's going to cover some of the topics we cover in the external libraries package as well.
1:31 So, you don't have to do it now but if you're feeling ambitious feel free to go though their quick start and give it a shot.
1:37 If it doesn't work, don't worry. We'll talk about more of it for the next chapter. But this is a really cool library
1:42 that helps you do logging the right way and it's what we use and it's been working great for years. Alright, get out there and have some fun
1:49 adding file IL to the games that you built.

Talk Python's Mastodon Michael Kennedy's Mastodon