Python: String Padding
There are 2 main ways we can add padding to a string in Python- Using string formatting functions, Using f-strings.
There are 2 main ways we can add padding to a string in Python- Using string formatting functions, Using f-strings.
To save created_by and updated_by user information in a laravel model- first create migrations for the the new fields, and then register events on model boot.
Facade works as an abstraction layer, over the underlying complex system. The client communicates with the facade, and the facade communicates with the subsystems. In this article, we discuss the implementation of the Facade Pattern in Python.
Decorator pattern is used to add some additional responsibilities to an object dynamically. We can add some new tasks, checking, etc. before and/or after the original functionality of the the object. Using the Decorator pattern we can extend the behavior, with property transparency, and without affecting other objects. In this article, we discuss the implementation of the Decorator Pattern in Python.
A decorator is a function that accepts a function and returns a function. We can perform the additional steps of operation(that we want to add before/after the original function), in the implementation of the decorator.
In composite pattern we use the same interface for the same object and composition of objects. This way we can treat and use the individual item object and item list/composition of object exactly the same way. In this article, we discuss the implementation of the Composite Pattern in Python.
Bridge pattern is used to separate/decouple the abstraction from the implementation, so that we can change those separately. The bridge pattern works as the communication for those two separate parts. In this article, we discuss the implementation of the Bridge Pattern in Python.
Adapter pattern is used to make two incompatible interfaces compatible and heavily used to accommodate functionality from an old(legacy) interface to a new interface. In this article, we discuss the implementation of the Adapter Pattern in Python.
Bubble sort is one of the most common sorting algorithms. It is a really simple sorting algorithm, but it is a very inefficient algorithm to handle large set of data.
In this algorithm, we go through the data set, and bubble up the largest number(item) to the end of the list. We do it one by one, and by traversing through the set of data, and swapping the largest number to the end.
Prototype pattern enables us to create an object from an existing object(by copying or cloning it), rather than creating an object from scratch. This process saves the overhead of the initialization process required for creating a new object from scratch. In this article, we discuss the implementation of the Prototype Pattern in Python.