Development Environment Setup
The most universal approach to installing Python is to visit the official Python download page at,
Normally this page will detect your operating system from the
useragent in your browser and select which install is appropriate for you.
There will be 64 and 32 bit versions for your operating system. At the time of writing this documentation, the option of downloading the 64bit version was the most common, and the version was 3.9.x.
The code in this documentation will be using a simplified generic style of Python that should work in all versions since Python version 3.
To test if you already have python on your system, depending on your operating system, whether Windows, Linux or Mac OSX, open a terminal/bash/cmd or PowerShell prompt.
Note the capital
V in the above command.
Sometimes python is named as
So you can also try
You are looking for a response that indicates you have Python 3 or above installed. Not an error, or
On my windows workstation, if I use PowerShell, the response is
I have Python3 already installed using the official python link from above.
If you are using a recent version of Linux or Mac OSX, then the command to check for the Python version on your system is most likely to be,
Remember to follow the official install instructions for your operating system at https://www.python.org/downloads/
All the code examples in this documentation can be viewed from my GitHub repository at https://github.com/Sean-Bradley/Design-Patterns-In-Python
If you have Git installed, you can download a copy locally using the command
or you can download a zip of all the code, by visiting this link in your browser
wget on Linux
1 2 3 4
You can then experiment with the code at your own pace and try out different variations.
If you would rather type the code from the documentation, then follow these further recommendations.
On my system, I have created a working folder on one of my spare drives,
E:\, and then created a new folder in it named
python_design_patterns, and then
cd into it. You can use a different folder name if you prefer.
1 2 3
Each section will be in a new folder named after the design pattern section.
I.e,. The code that I write for the Factory pattern will be in its own subfolder named
1 2 3
If you are working on Windows, then I recommend to also install VSCode to use as your IDE when learning Python.
This is optional and you may prefer to use Notepad or any other popular IDE that you can download or use online that will also assist you when writing Python.
You can download VSCode from https://code.visualstudio.com/download
You can then open VSCode from your current working folder by typing
And VSCode will open ready for you in your working folder where you can use it to add new files or folders as needed.