Jan. 8, 2024, 8:58 a.m. | Bhavani Ravi

DEV Community dev.to

When defining a subclass, there are different ways to call the __init__ method of a parent class. Let’s start with a base class and go through each of these methods.


For this blog, it’s better that you open a sample.py python file and follow along.



class Base(object):
def __init__ (self):
print "Base created"





Method 1 :: Using Parent Reference Directly



class ChildA(Base):
def __init__ (self):
Base. __init__ …

blog call class django file flask python sample through

Founding AI Engineer, Agents

@ Occam AI | New York

AI Engineer Intern, Agents

@ Occam AI | US

AI Research Scientist

@ Vara | Berlin, Germany and Remote

Data Architect

@ University of Texas at Austin | Austin, TX

Data ETL Engineer

@ University of Texas at Austin | Austin, TX

DevOps Engineer (Data Team)

@ Reward Gateway | Sofia/Plovdiv