A singleton is a design pattern for creating only one instance of a class. Modules in Python are singletons by nature. A classic singleton checks whether the instance was created earlier; if not, it creates and returns it. The Borg singleton uses shared state for all objects. In the example shown in the chapter, we used the Singleton
class for accessing a shared resource and a set of URLs to fetch images from, and both threads used it to properly parallelize their work.
In the next chapter, you will learn about other patterns for creating objects, including: factory, the factory method, the abstract factory, and how they help to build objects.