Chapter 8. Working with Files

Terms in This Chapter

  • Class instance

  • Comment

  • Data persistence

  • Data structure

  • Document string

  • Dump

  • File

  • File object

  • File pointer

  • for, if, and while statements

  • for loop

  • Java Virtual Machine

  • Method

  • Mode

  • newline

  • Object instance

  • pickle module

  • Scaffolding

  • try … except

  • try … finally

  • while loop

I've written programs that read and write data from files in Java, Delphi, Visual Basic, C++, and C. None have such a straightforward and easy approach to dealing with files as Python's. In this chapter we'll be covering file input and output, which is important for saving data. First we'll cover simple I/O; later we'll deal with persisting class instances.

Writing a program that resides only in memory is good for illustration, but eventually you'll ...

Get Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython 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.