Running python

Reference:
cd mon_projet

python -m venv mon_venv

source mon_venv/bin/activate

# Sur windows
mon_venv\Scripts\activate

deactivate

install requirement

pip install -r requirements.txt

initiation

GoF Design Patterns in Python

GoF design patterns are a set of 23 design patterns that were described in the book "Design Patterns: Elements of Reusable Object-Oriented Software".

Table 1. Here is a list of GoF design patterns

Name

Description

Factory Method

Creates objects without specifying the exact class to be instantiated.

Abstract Factory

Creates families of related or dependent objects without specifying their concrete class.

Builder

Separates the construction of a complex object from its representation so that the same construction process can create different representations.

Prototype

Creates new objects by copying an existing prototype.

Singleton

Restricts the instantiation of a class to a single object.

Adapter

Converts the interface of a class into another interface that the client expects.

Bridge

Decouples an abstraction from its implementation so that the two can vary independently.

Composite

Composes objects into tree structures to represent part-whole hierarchies.

Decorator

Dynamically attaches additional responsibilities to an object.

Facade

Provides a unified interface to a set of interfaces in a subsystem.

Flyweight

Reduces the cost of creation and use of lightweight objects.

Proxy

Provides a surrogate or placeholder for another object to control access to it.

Chain of Responsibility

Allows more than one object to handle a request.

Command

Encapsulates a request in an object, thereby allowing clients to be parameterized with different requests, queues, or logs, and to support undoable operations.

Interpreter

Gives a representation of a language’s grammar and uses this representation to interpret sentences in that language.

Iterator

Provides a way to sequentially access the elements of an aggregate object without exposing its underlying representation.

Mediator

Reduces complex dependencies between objects by making them communicate only via a mediator object.

Memento

Provides the ability to restore an object to its previous state (without violating encapsulation).

Observer

Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.

State

Allows an object to change its behavior when its internal state changes.

Strategy

Defines a family of algorithms, encapsulates each of them, and makes them interchangeable.

Template Method

Defines the skeleton of an algorithm in a method, deferring some steps to subclasses.

Visitor

Allows defining a new operation to be performed on a structure of objects without changing the classes of the objects on which it operates.

Functional programming

Library

URL

Description

PyMonad

https://github.com/jasondelaat/pymonad

PyMonad is an implementation of monadic data structures in Python based on programming languages such as Haskell and F# with implementations for the most commonly used monad types in functional programming.https://www.miguelfarrajota.com/2021/06/monads-in-python-with-pymonad/[article]

PyFunctional

https://github.com/EntilZha/PyFunctional/

PyFunctional is a Python library for functional programming that provides tools for working with pure functions and iterables.

Toolz

https://toolz.readthedocs.io/en/latest/

Toolz is a Python library for functional programming that provides tools for working with pure functions and iterables.

Fn.py

https://github.com/kachayev/fn.py

Fn.py is a Python library for functional programming that provides tools for working with pure functions and iterables.

Coconut

https://coconut-lang.org/

Coconut adds several features to Python for functional programming, including pattern matching.https://stackoverflow.com/questions/11909681/are-there-pattern-matching-functions-in-python-like-this[conversation sof]

side effects

loops

# impérative way
result = []
for i in inputs:
    x = f(g(i))
    result.append(x)

# idiomatic way
result = map(comp(f,g), inputs)

Related articles