Next / Previous / Contents / TCC Help System / NM Tech homepage

6. Source code for PathInfo

Here is the source code for the pathinfo.py module containing the PathInfo class.

6.1. Prologue

The code for the pathinfo.py module starts with the conventional Python documentation string.

pathinfo.py
"""pathinfo.py:  Object to represent a snapshot of a file's status.

  For documentation in "literate programming" style, see:
    http://www.nmt.edu/help/lang/python/examples/pathinfo/
"""

Next comes the importation of the standard Python modules we use:

  • The os module supports Posix file systems and other operating system functions.

  • The stat module supplies additional declarations needed for interpreting the information that comes out of the os.stat() and os.lstat() functions.

  • We use the time module for translating and formatting file timestamps. In Python 2.3 and later, the datetime module is now recommended, but we'll use the older version out of consideration for those who have older Python installs.

pathinfo.py
#================================================================
# Imports
#----------------------------------------------------------------

import os, stat, time