2.14. Files and the open() Built-in Function

File access is one of the more important aspects of a language once you are comfortable with the syntax; there is nothing like the power of persistent storage to get some real work done.

How to Open a File

							handle = open( file_name, access_mode='r')

The file_name variable contains the string name of the file we wish to open, and access_mode is either 'r' for read, 'w' for write, or 'a' for append. Other flags which can be used in the access_mode string include the '+' for dual read-write access and the 'b' for binary access. If the mode is not provided, a default of read-only ('r') is used to open the file.

CORE NOTE: What are attributes?

Attributes are items associated with a piece of data. Attributes ...

Get Core Python Programming 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.