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

Software Engineer for AI Training Data (School Specific)

@ G2i Inc | Remote

Software Engineer for AI Training Data (Python)

@ G2i Inc | Remote

Software Engineer for AI Training Data (Tier 2)

@ G2i Inc | Remote

Data Engineer

@ Lemon.io | Remote: Europe, LATAM, Canada, UK, Asia, Oceania

Artificial Intelligence – Bioinformatic Expert

@ University of Texas Medical Branch | Galveston, TX

Lead Developer (AI)

@ Cere Network | San Francisco, US