Skip to Content
Software Architecture with Python
book

Software Architecture with Python

by Anand Balachandran Pillai
April 2017
Intermediate to advanced
556 pages
11h 5m
English
Packt Publishing
Content preview from Software Architecture with Python

Patterns in Python – creational

In this section, we will take a look at a few of the common creational patterns. We will start with Singleton, and then go on to Prototype, Builder, and Factory, in that order.

The Singleton pattern

The Singleton pattern is one of the most well-known and easily understood patterns in the entire pantheon of design patterns. It is usually defined as:

A Singleton is a class which has only one instance and a well-defined point of access to it.

The requirements of a Singleton can be summarized as follows:

  • A class must have only one instance accessible via a well-known access point.
  • The class must be extensible by inheritance without breaking the pattern.
  • The simplest Singleton implementation in Python is shown next. It is ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Architecture Patterns with Python

Architecture Patterns with Python

Harry Percival, Bob Gregory

Publisher Resources

ISBN: 9781786468529Supplemental Content