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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.