Understanding Pass-by-Value vs. Pass-by-Reference in Python

One of the most commonly asked questions by Python developers is: “Does Python use pass-by-value or pass-by-reference?” Does Python use pass-by-value or pass-by-reference? The answer isn’t as straightforward as it is in languages like C++ or Java. Python follows a “pass-by-object-reference” model, which is sometimes referred to as “pass-by-assignment.” This article will explore how Python … Read full article: Understanding Pass-by-Value vs. Pass-by-Reference in Python

Python tips and tricks for competitive programming

Here are some Python hacks for competitive programming that can help you write efficient and concise code. String Operation Join Synatx Example Perform a join on an integer Solution Dictionary When using a dictionary as an iterable, the returned values are the keys, not the values. Just like we are searching whether a key exists … Read full article: Python tips and tricks for competitive programming

Understanding Metaclasses in Python

In Python, metaclasses are a powerful and advanced feature that allows developers to control the behavior of class creation. While they may seem complex at first, understanding metaclasses can provide deep insights into Python’s object-oriented nature. What is a Metaclass? A metaclass is a class that defines how other classes behave. Just like a class … Read full article: Understanding Metaclasses in Python

Class Methods, Static Methods, and Instance Methods in Python

class method static method instance method

Python provides three types of methods in a class: Instance Methods, Class Methods, and Static Methods. Each serves a different purpose and is used based on the requirement. In this article, we’ll explore these methods with examples to understand their differences and use cases. Instance Methods Instance methods are the most commonly used methods in … Read full article: Class Methods, Static Methods, and Instance Methods in Python

Python’s Dunder (Magic) Methods with Examples

Dunder Magic Method

Python provides a set of special methods, also known as dunder (double underscore) methods or magic methods, that allow developers to define how objects of a class interact with built-in functions and operators. These methods begin and end with double underscores (__method__) and enable customisation of object behavior. Object Creation & Initialization These methods control … Read full article: Python’s Dunder (Magic) Methods with Examples

Template in FastAPI

In FastAPI, templates are commonly used to render HTML pages dynamically. FastAPI supports templates through libraries like Jinja2, which allows you to inject dynamic content into HTML files. Installing Jinja2 Setting Up Templates in FastAPI You need to use Jinja2Templates from fastapi.templating and set up a templates directory. Project Structure Example Creating Template Files Inside … Read full article: Template in FastAPI

A Complete Guide to Middleware in FastAPI

Middleware

FastAPI is a high-performance web framework that simplifies building APIs with Python. One of its most powerful features is middleware, which allows developers to modify requests and responses globally before they reach the route handlers. What is Middleware? Middleware is a function that runs before and after every request in FastAPI. It can: FastAPI uses … Read full article: A Complete Guide to Middleware in FastAPI

Introduction to Pydantic: Data Validation and Serialization in Python

Pydantic

Pydantic is a powerful Python library for data validation and settings management. It is particularly popular in modern Python applications because it can enforce data correctness using Python-type hints. This makes it an essential tool for backend developers, especially those working with APIs and data processing tasks. Why Use Pydantic? Getting Started with Pydantic Installation … Read full article: Introduction to Pydantic: Data Validation and Serialization in Python

Popular Python Web Server

Python Web Server

A web server is a software that handles incoming requests from clients (usually browsers) and serves responses, such as web pages, data, or files. Python web servers can handle various protocols and are often used for serving websites, APIs, and static content. Standards for Python Web Applications to communicate with web servers Standards for Python … Read full article: Popular Python Web Server