Python Design Patterns - Gist


Advertisements

Python is an open source scripting language, which is high-level, interpreted, interactive and object-oriented. It is designed to be highly readable. The syntax of Python language is easy to understand and uses English keywords frequently.

Features of Python Language

In this section, we will learn about the different features of Python language.

Interpreted

Python is processed at runtime using the interpreter. There is no need to compile program before execution. It is similar to PERL and PHP.

Object-Oriented

Python follows object-oriented style and design patterns. It includes class definition with various features like encapsulation, polymorphism and many more.

Portable

Python code written in Windows operating system and can be used in Mac operating system. The code can be reused and portable as per the requirements.

Easy to code

Python syntax is easy to understand and code. Any developer can understand the syntax of Python within few hours. Python can be described as “programmer-friendly”

Extensible

If needed, a user can write some of Python code in C language as well. It is also possible to put python code in source code in different languages like C++. This makes Python an extensible language.

Important Points

Consider the following important points related to Python programming language −

  • It includes functional and structured programming methods as well as object-oriented programming methods.

  • It can be used as scripting language or as a programming language.

  • It includes automatic garbage collection.

  • It includes high-level dynamic data types and supports various dynamic type checking.

  • Python includes a feature of integration with C, C++ and languages like Java.

How to download python language in your system?

To download Python language in your system, follow this link −

https://www.python.org/downloads/

Python Language

It includes packages for various operating systems like Windows, MacOS and Linux distributions.

The Important Tools in Python

In this section, we will learn in brief about a few important tools in Python.

Python Strings

The basic declaration of strings is as follows −

str = 'Hello World!'

Python Lists

The lists of python can be declared as compound data types separated by commas and enclosed within square brackets ([]).

list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]
tinylist = [123, 'john']

Python Tuples

A tuple is dynamic data type of Python, which consists of number of values separated by commas. Tuples are enclosed with parentheses.

tinytuple = (123, 'john')

Python Dictionary

Python dictionary is a type of hash table. A dictionary key can be almost any data type of Python. The data types are usually numbers or strings.

tinydict = {'name': 'omkar','code':6734, 'dept': 'sales'}

What constitutes a design pattern in Python?

Python helps in constituting a design pattern using the following parameters −

  • Pattern Name
  • Intent
  • Aliases
  • Motivation
  • Problem
  • Solution
  • Structure
  • Participants
  • Constraints
  • Sample Code
Advertisements