CHAPTER 9

FILES AND EXCEPTIONS

CHAPER OUTLINE

9.1 File Handling

9.2 Writing Structures to a File

9.3 Errors and Exceptions

9.4 Handling Exceptions using try…except

9.5 File Processing Example

Programs that we have developed so far take data from the user in an interactive manner. Such data remain in memory only during the lifetime of the program. Often we want to store data permanently, in the form of files that usually reside on disks, so that it is available as and when required. For example, for login application, we would like to validate the user name and password entered by a user against the names and passwords of valid users stored permanently in a file. By default, Python provides a standard input file and a standard output file to ...

Get Python Programming: A modular approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.