Next / Previous / Contents / Shipman's homepage

46. The Singleton class

The code below implements the functionality described in Section 5, “The Singleton base class: A classic design pattern”. The code is kept in a separate file, singleton.py, and not in the logscan.py file, because it may be useful elsewhere.

A Python implementation of the Singleton pattern is given on page 84 of this work:

Martelli, Alex. Python in a nutshell. O'Reilly, 2003, 1st ed., ISBN 0-596-00188-6.

The present work is basically an elaboration of that code with literate annotation.