-
Book Overview & Buying
-
Table Of Contents
Python Illustrated
By :
That’s it for handling files and exceptions. I hope this chapter wasn’t as boring to you as Wiesje predicted it would be. Even if it was a bit boring, you should now understand the importance of this topic. You learned that by storing data in files instead of just variables, you can keep your progress after a program has stopped running.
An important part of handling files is knowing where to find the files. This is why we dove into file paths. There are two kinds of paths: absolute and relative. An absolute path starts at the root directory of your system, and a relative path starts from the folder your program is currently in. Paths work differently on different operating systems. This is where Python’s os.path module comes to the rescue. It lets you deal with paths in a more platform-independent way.
We discussed several types of files that we can read, write, and update using Python code. The first thing you need to do when you want to do something...