Singleton pattern
The singleton pattern is one of the most controversial patterns; many have accused it of being an "anti-pattern"; a pattern that should be avoided, not promoted. In Python, if someone is using the singleton pattern, they're almost certainly doing something wrong, probably because they're coming from a more restrictive programming language.
So why discuss it at all? Singleton is one of the most famous of all design patterns. It is very useful in overly object-oriented languages, and is a vital part of object-oriented programming. Finally, the idea behind singleton is useful, even if we implement that idea in a totally different way in Python.
The basic idea behind the singleton pattern is to allow exactly one instance of a certain object to exist. Typically, this object is a sort of manager class like those we discussed in Chapter 5. Such objects often need to be referenced by a wide variety of other objects, and passing references to the manager object around to the methods...