-
Book Overview & Buying
-
Table Of Contents
Python Illustrated
By :
So far, we’ve talked a lot about storing information in variables, lists, dictionaries, and tuples. However, all of that stored data disappears once our Python program stops running. Imagine if every time you closed your code, you lost all the progress on your cat toy inventory, or the results of all the hard work that goes into tracking bird sightings. Not ideal to say the least.
That’s where this chapter comes in. We’ll learn how we can make programs that are going to alter files, for example, writing the cat toy inventory to a file. That way, we can see the results of our efforts later, and if we want, we can load it again the next time the program runs.
When handling files, it’s important to also deal with problems related to handling files. What if a file that you rely on turns out to be missing or inaccessible, for example? This would give an error if we don’t deal with it. And a problem like this is something...