October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk1 min

How to Create and Use an Empty Constructor in Python

Python classes can omit __init__ when no setup is needed, or define def __init__(self): pass for an explicit empty initializer. Create instances by calling the class, not by passing self.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To make a Python instance without custom setup, either omit __init__ or define an empty one with pass. For a class with an explicit empty initializer, write def __init__(self): and create an instance with Example()—Python supplies self automatically.

Omit __init__ when there is nothing to initialize

A class does not need to define an initializer just to be instantiable. If the class has no custom setup to perform, Python’s inherited construction behavior lets you create a no-argument instance:

class Marker:
    pass

marker = Marker()

This is often the clearest choice for a class with no per-instance state or setup. Calling a class creates an object; an empty initializer is not required. See the Python 3.14.8 classes tutorial for the instantiation behavior.

Write an explicit empty initializer with pass

If you want to show the initialization hook explicitly—for example, in a teaching example or as a placeholder for planned setup—you can define it with a body containing pass:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
class Marker:
    def __init__(self):
        pass

marker = Marker()

pass is a statement that does nothing, used here because a Python function body cannot be left blank. The call remains Marker(), with no argument for self.

Understand self and constructor arguments

For an instance method such as __init__, Python supplies the instance as the first argument when the method is called. By convention, that parameter is named self; it is not a special keyword, but the method must accept it. Therefore, write def __init__(self):, not def __init__():, and normally create an object by calling the class rather than calling __init__ yourself.

An initializer written as def __init__(self): accepts no additional arguments from the caller. Example() works; Example(value) raises TypeError unless the class’s construction methods accept that argument. If a value should be optional, give it a default:

class User:
    def __init__(self, name="Guest"):
        self.name = name

user = User()

Add initialization when the instance needs state

An empty initializer does not create application-specific attributes. Assign an attribute before code tries to use it. For per-instance mutable state, create the value inside __init__ so each object gets its own value:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
class Notebook:
    def __init__(self):
        self.pages = []

first = Notebook()
second = Notebook()
first.pages.append("Notes")

print(first.pages)   # ['Notes']
print(second.pages)  # []

Putting pages = [] directly in the class body instead would make it a class attribute shared through the class, rather than a separate list for each notebook.

Know what __init__ does—and what it does not

Python’s construction process uses __new__ to create an object, then calls __init__ to initialize it when the created object is an instance of the requested class. Ordinary classes rarely need a custom __new__; an empty initializer question normally concerns only __init__. The Python data model reference describes the distinction.

__init__ must return None. Do not return self or another value from it; a non-None return value causes TypeError.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Handle a base class initializer in a subclass

When a subclass defines its own __init__, Python does not automatically run the base class’s initializer. If that base initializer performs setup the subclass relies on, call it explicitly with super().__init__():

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
class Base:
    def __init__(self):
        self.ready = True

class Child(Base):
    def __init__(self):
        super().__init__()
        self.name = "example"

If the base initializer is empty, the call performs no setup; whether to include it depends on the base class’s contract.

Choose the form that matches the class

Form Use it when Effect
Omit __init__ The class has no per-instance initialization to perform. Concise; instances can use the inherited no-argument construction behavior.
def __init__(self): pass An explicit initialization hook helps explain the class or gives you a place to add setup. Valid, but currently performs no setup and accepts no extra caller-supplied arguments.

Both are valid. Prefer omission when the method would do nothing; define an initializer when it has a real setup job or when an explicit hook is useful.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.