Access object within another objects in Python
Prerequisite: Basics of OOPs in Python...
read more
Create Derived Class from Base Class Universally in Python
In object-oriented programming, the concept of inheritance allows us to create a new class, known as the derived class, based on an existing class, referred to as the base class. This facilitates code reusability and structuring. Python provides a versatile way to create derived classes from base classes universally, allowing for flexibility and scalability in your code....
read more
Create Class Objects Using Loops in Python
We are given a task to create Class Objects using for loops in Python and return the result, In this article we will see how to create class Objects by using for loops in Python....
read more
Single Aad Double Underscores in Python
In Python, naming conventions play a crucial role in code readability and maintainability. Single and double underscores, when used in names, convey specific meanings and conventions. These naming conventions are widely adopted in the Python community and are often utilized in various contexts, including class attributes and special methods. In this article, we will learn about single and double underscores in Python...
read more
Python – Access Parent Class Attribute
A class is a user-defined blueprint or prototype from which objects are created. Classes provide a means of bundling data and functionality together. Creating a new class creates a new type of object, allowing new instances of that type to be made. Each class instance can have attributes attached to it for maintaining its state. Class instances can also have methods (defined by its class) for modifying its state....
read more
Polymorphism in Python
What is Polymorphism: The word polymorphism means having many forms. In programming, polymorphism means the same function name (but different signatures) being used for different types. The key difference is the data types and number of arguments used in function....
read more
What is a clean and Pythonic way to have multiple constructors in Python?
Python does not support explicit multiple constructors, yet there are some ways to achieve multiple constructors....
read more
Dunder or magic methods in Python
Python Magic methods are the methods starting and ending with double underscores ‘__’. They are defined by built-in classes in Python and commonly used for operator overloading....
read more
Multilevel Inheritance in Python
Python is one of the most popular and widely used Programming Languages. Python is an Object Oriented Programming language which means it has features like Inheritance, Encapsulation, Polymorphism, and Abstraction. In this article, we are going to learn about Multilevel Inheritance in Python....
read more
Difference between DataClass vs NamedTuple vs Object in Python
Data Class: Data Class is a type of class that is used to store data without any functionality. These data classes are just regular classes having the main purpose to store state and data without knowing the constraints and logic behind it. Whenever you create a class that mostly contains attributes and certain properties to deal with the data and its representation....
read more
Why Python Uses ‘Self’ as Default Argument
Python, a versatile and widely used programming language, follows object-oriented principles in its design. One of the distinctive features of Python is the use of the keyword ‘self’ as a default argument in class methods. This choice plays a crucial role in maintaining the integrity of object-oriented programming (OOP) concepts and ensures proper handling of instance variables and methods. In this article, we’ll delve into why Python uses ‘self’ as a default argument....
read more
How to Use __call__() Method Instead of __new__() of a Metaclass in Python?
In Python, metaclasses provide a way to customize class creation. The __new__ and __init__ methods are commonly used in metaclasses, but there’s another powerful tool at your disposal: the __call__ method. While __new__ is responsible for creating a new instance of a class, __call__ allows you to control what happens when an instance is called as a function. This article explores the __call__ method of a metaclass, its syntax, and advantages, and provides three code examples demonstrating how to use it instead of __new__....
read more