Mutable default arguments don't generally do what you want. Instead, try this:

class Node:
     def __init__(self, wordList=None, adjacencyList=None):
        if wordList is None:
            self.wordList = []
        else:
             self.wordList = wordList 
        if adjacencyList is None:
            self.adjacencyList = []
        else:
             self.adjacencyList = adjacencyList 
Answer from Michael J. Barber on Stack Overflow
🌐
BeginnersBook
beginnersbook.com › 2018 › 03 › python-constructors-default-and-parameterized
Python Constructors – default and parameterized
We have two types of constructors in Python. 1. default constructor – this is the one, which we have seen in the above example. This constructor doesn’t accept any arguments.
🌐
GeeksforGeeks
geeksforgeeks.org › python › constructors-in-python
Constructors in Python - GeeksforGeeks
July 11, 2025 - Used to initialize the created object. Constructors can be of two types. A default constructor does not take any parameters other than self.
Discussions

class - Does Python have a default constructor for classes? - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... I was asking myself whether Python3.6 had a default constructor for classes. So I wrote some code to test this. More on stackoverflow.com
🌐 stackoverflow.com
Default values in class definition and constructor? Is this the right way?

Don't use class attributes for that, that's not what they are there for. Use default arguments:

def __init__(self, name='Undefined', number=-1):
    self.name = name
    self.number = number

If any of the arguments are mutable, then you need to use the usual idiom:

def __init__(self, foo=None):
    self.foo = [] if foo is None else foo
More on reddit.com
🌐 r/learnpython
26
4
August 15, 2015
what are constructors in python?
Construction is implicit in python, __init__ is used for initialization of a new object. There is a __new__ constructor, but you'll likely not need to write one ever. https://docs.python.org/3/reference/datamodel.html#classes 3.2.8.8. Classes Classes are callable. These objects normally act as factories for new instances of themselves, but variations are possible for class types that override __new__() . The arguments of the call are passed to __new__() and, in the typical case, to __init__() to initialize the new instance. More on reddit.com
🌐 r/learnpython
23
11
June 30, 2025
Explain Constructors in Python
Constructors play a crucial role in the object-oriented programming paradigm by ensuring that objects are properly configured upon creation. ... In Python, a default constructor is a constructor that is automatically provided by the language if no constructor is explicitly defined within a class. More on accuweb.cloud
🌐 accuweb.cloud
1
June 18, 2024
🌐
Wiingy
wiingy.com › home › learn › python › constructors in python
Constructors in Python (With Examples) - Wiingy
April 15, 2025 - Code optimization: Using ... an object. A default constructor is a constructor that takes no arguments and is defined implicitly by Python if no other constructor is defined....
🌐
Tutorialspoint
tutorialspoint.com › python › python_constructors.htm
Python - Constructors
However, you can give any name to the first parameter, not necessarily self. ... The Python constructor which does not accept any parameter other than self is called as default constructor.
🌐
Dummies
dummies.com › article › technology › programming-web-design › python › how-to-create-a-constructor-in-python-203515
How to Create a Constructor in Python | dummies
June 30, 2025 - The name of a constructor is always the same, __init__(). The constructor can accept arguments when necessary to create the object. When you create a class without a constructor, Python automatically creates a default constructor for you that doesn’t do anything.
Find elsewhere
🌐
PYnative
pynative.com › home › python › python object-oriented programming (oop) › constructors in python
Constructor in Python [Guide] – PYnative
August 28, 2021 - In Python, every class has a constructor, but it’s not required to define it explicitly. Defining constructors in class is optional. Python will provide a default constructor if no constructor is defined.
🌐
Educative
educative.io › answers › what-is-a-constructor-in-python
What is a constructor in Python?
Constructors in C++, Dart, or Java ... is invoked whenever an object is created. ... The default constructor is a constructor that takes no arguments....
🌐
Medium
medium.com › @imshivam077 › day-30-constructors-in-python-84d03e64484d
Day-30 — Constructors In Python. Constructors | by Shivam Shukla | Medium
December 18, 2023 - When the constructor doesn’t accept any arguments from the object and has only one argument, self, in the constructor, it is known as a Default constructor.
🌐
Analytics Vidhya
analyticsvidhya.com › home › constructors in python: definition, types, and rules
Constructors in Python: Definition, Types, and Rules - Analytics Vidhya
May 26, 2025 - Let’s delve into each type of Python constructor with clear examples. ... The default constructor is automatically invoked when an object is created without any explicit constructor.
🌐
Scaler
scaler.com › home › topics › constructor in python
Constructor in Python - Scaler Topics
February 11, 2022 - When a class is defined without an explicit constructor in Python, Python automatically provides a default constructor.
🌐
Real Python
realpython.com › python-class-constructor
Python Class Constructors: Control Your Object Instantiation – Real Python
January 19, 2025 - If you don’t override .__new__() or .__init__() in your class, Python will use the default implementations from the built-in object class. They’re typically sufficient for most use cases unless you need custom behavior during object creation or initialization. Take the Quiz: Test your knowledge with our interactive “Python Class Constructors: Control Your Object Instantiation” quiz.
🌐
ScholarHat
scholarhat.com › home
Understanding Constructors in Python
September 10, 2025 - Use a default constructor for predefined attributes, a parameterized constructor for custom values, and a non-parameterized constructor for initializing default values or performing operations. By choosing the right constructor, you can make your Python code more efficient and easier to manage.
🌐
Accuweb
accuweb.cloud › home › explain constructors in python
Explain Constructors in Python
June 18, 2024 - Constructors play a crucial role ... In Python, a default constructor is a constructor that is automatically provided by the language if no constructor is explicitly defined within a class....
🌐
Python Geeks
pythongeeks.org › python geeks › learn python › constructor in python with examples
Constructor in Python with Examples - Python Geeks
June 11, 2021 - Non-Parameterized vs Parameterized Constructor in Python · A constructor is a necessary tool for object creation. If we don’t define a constructor, then Python creates a non-parameterized constructor with an empty body. This constructor is ...
🌐
DataFlair
data-flair.training › blogs › python-constructor
Python Constructor- Parameterized and Non-Parameterized - DataFlair
July 15, 2025 - Here, we did not define a constructor, but Python instantiated that object anyway! This must mean it provides a default constructor that shows up when we do not provide any.
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › constructor in python
Constructor in Python: Comprehensive Guide and Examples | upGrad
January 5, 2026 - In this example, the Person class ... class are created. A default constructor is provided by Python automatically if you don't define any constructor explicitly in your class....