Getting ready

It's important to separate two concepts:

  • The path that identifies a file
  • The contents of the file

The path provides an optional sequence of directory names and the final filename. It may provide some information about the file contents via the filename extension. The directory includes the files name, information about when the file was created, who owns it, what the permissions are, how big it is, and other details. The contents of the file are separate from the directory information and the name.

Often, a filename has a suffix that can provide a hint as to what the physical format is. A file ending in .csv is likely a text file that can be interpreted as rows and columns of data. This binding between name and physical format ...

Get Modern Python Cookbook 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.