You know you can save values in variables, but once your program ends poof!—they’re gone forever. That’s where persistent storage comes in—storage that allows your values and data to stick around a while. Most of the devices you’re going to run Python on also have persisistent storage, like hard drives and flash cards, or they may have access to storage in the cloud as well. In this chapter you’ll see how to write code to store and retrieve data from files. What good is that? Oh, anytime you want to save a user’s configuration, store the results of your big analysis for the boss, read an image into your code to process it, write some code to search a decade’s worth of email messages, reformat some data to be used in your spreadsheet app—we could go on and on, but we should probably start the chapter now.
No, that’s not a political statement! We’re being serious here. We’re talking about creating our own version of a game that is in the spirit of the popular Mad Libs™ games—we’ll call our version Crazy Libs.
If you didn’t play a Mad Libs–style game as a kid, here’s how it works:
Ask a friend to give you a word for each blank noun, verb, and adjective, but don’t show your friend ...