Blog

python tutorials and learn python

Created with Sketch.

Python Interface Segregation Principle

Python Interface Segregation Principle Summary: in this tutorial, you’ll learn about the interface segregation principle and how to apply it in Python. Introduction to the interface segregation principle The interface segregation principle is one of five SOLID principles in object-oriented programming: S – Single responsibility Principle O – Open-closed Principle L – Liskov Substitution Principle I – Interface Segregation…
Read more

Python Liskov Substitution Principle

Python Liskov Substitution Principle Summary: in this tutorial, you’ll learn about the Liskov Substitution Principle and how to implement it in Python. Introduction to the Liskov substitution principle The Liskov substitution principle (LSV) is one of the five principles in the SOLID principles. The L in SOLID stands for the Liskov substitution principle. S – Single…
Read more

Python Open–closed principle

Python Open–closed principle Summary: in this tutorial, you’ll learn about the open-closed principle to extend the system without directly modifying existing code. Introduction to the open-closed principle The open-closed principle is one of the five principles in the SOLID principle. The letter O in the SOLID stands for the open-closed principle. S – Single Responsibility Principle…
Read more

Python Single Responsibility Principle

Python Single Responsibility Principle Summary: in this tutorial, you’ll learn about the single responsibility principle and how to implement it in Python. What is SOLID SOLID is an abbreviation that stands for five software design principles compiled by Uncle Bob: S – Single responsibility Principle O – Open-closed Principle L – Liskov Substitution Principle I – Interface Segregation Principle D –…
Read more

Python enum auto

Python enum auto Summary: in this tutorial, you’ll learn about the enum auto() function to generate unique values for enumeration members. Introduction to the enum auto() function The following example defines an enumeration with three members whose values are 1, 2, and 3: from enum import Enum class State(Enum): PENDING = 1 FULFILLED = 2…
Read more

Customize and Extend Python Enum Class

Customize and Extend Python Enum Class Summary: in this tutorial, you’ll learn how to customize and extend the custom Python enum classes. Customize Python enum classes Python enumerations are classes. It means that you can add methods to them, or implement the dunder methods to customize their behaviors. The following example defines the PaymentStatus enumeration…
Read more

Python Enum aliases & @enum.unique Decorator

Python Enum aliases & @enum.unique Decorator   Summary: in this tutorial, you’ll learn about enumeration member aliases and how to use the enum unique decorator to ensure the uniqueness of member values. Introduction to the enum aliases By definition, the enumeration member values are unique. However, you can create different member names with the same…
Read more

Python Enumeration

Python Enumeration Summary: in this tutorial, you’ll learn about Python enumeration and how to use it effectively. Introduction to the Python Enumeration By definition, an enumeration is a set of members that have associated unique constant values. Enumeration is often called enum. Python provides you with the enum module that contains the Enum type for…
Read more

Python Abstract Classes

Python Abstract Classes   Summary: in this tutorial, you’ll learn about Python Abstract classes and how to use it to create a blueprint for other classes. Introduction to Python Abstract Classes In object-oriented programming, an abstract class is a class that cannot be instantiated. However, you can create classes that inherit from an abstract class.…
Read more

Python __slots__

Python __slots__ Summary: in this tutorial, you will learn about the Python __slots__ and how how to use it to make your class more efficient. Introduction to the Python __slots__ The following defines a Point2D class that has two attributes including x and y coordinates: class Point2D: def __init__(self, x, y): self.x = x self.y…
Read more