This document describes a small Python class called
This class was written for two reasons:
Each instance of a
PathInfo object represents a snapshot of
the state of a file, directory, or other such object,
with a number of methods to help you look at aspects
of the file such as its size and permissions.
It is a good example of a small Python class for use in introducing object-oriented programming to new Python programmers.
Also, we present some small scripts that use the
object for practical, everyday tasks:
When you have a lot of disk space tied up and want to
find some large files you can offload or delete, you
want to see a list of your largest files in descending
order by size. See Section 3, “
bigfiles.py: Where are my biggest files?”.
Sometimes you want to look at files according to when
they were last modified. For example, you might want
to find the files you've used least recently to help
you weed out unused files. Or you might be trying to
find some files inside a large file structure, and you
don't know where they are, but you do remember
when you were working on them.
See Section 4, “
oldfiles.py: Sorting your files by modification date”.
This project exhibits a number of useful software technologies. In addition to object-oriented programming:
This document includes all the Python source code for
PathInfo object and the example scripts that
use it. For more on this practice, called
literate programming, see the
literate programming page.
The code was developed using the Cleanroom or zero-defect style; for the author's practice and conventions, see the author's Cleanroom page.
Source files contained in this package include: