Learn Python
>>> oop_fundamentals.method_overriding_overloading

Method Overriding vs Overloading in Python

#concept

Overriding means a subclass redefines a method it inherited, replacing the parent's version — this is fully supported in Python and used constantly. Overloading means defining multiple versions of the same method that differ only by their arguments, letting the "right" one run based on how it's called — common in languages like Java or C++, but Python doesn't support it directly at all; a later definition of the same method name simply replaces the earlier one entirely.

#how it works
1

Overriding redefines an inherited method

A subclass’s version takes priority for instances of that subclass.

2

Overriding is genuine, core Python behavior

Central to how polymorphism and inheritance work together.

3

Overloading means multiple signatures, one name

Several methods sharing a name but differing in parameter types or count — the traditional definition.

4

Python has no built-in support for this

Defining a method twice in the same class just keeps the last definition, silently discarding the first.

5

Python reaches for other tools instead

Default arguments, *args, or functools.singledispatch cover the same flexibility overloading provides elsewhere.

#example
class Greeter:
def greet(self, name):
print(f"Hello, {name}")
 
def greet(self, name, formal=False):
if formal:
print(f"Good day, {name}")
else:
print(f"Hello, {name}")
 
g = Greeter()
g.greet("Ada")
g.greet("Ada", formal=True)
Output
Hello, Ada
Good day, Ada
1Two greet() methods are defined in the same class — the second definition completely replaces the first, since Python doesn’t support true overloading.
2Only the second version exists by the time Greeter is actually used, which is why calling greet("Ada") still works — it’s using the second definition’s default formal=False.
3Python’s usual substitute for overloading is exactly this: one method with a default argument, rather than two separate method definitions with the same name.
#use cases
Customizing inherited behavior in a subclass, a routine and expected use of overriding
Understanding why defining the same method name twice in a class silently loses the first version, a common beginner surprise
Using default arguments or *args to mimic 'different ways to call this' instead of reaching for true overloading
Reaching for functools.singledispatch on the rare occasion genuine type-based overloading is really needed

Recommended resourcesAffiliate links · may earn us a commission

Recommended for learners

Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Pro code editor & AI assistantWrite, debug and explain code faster while you practice the patterns here.Try it free Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books

Practice what you learned

Re-implement each visualized algorithm in Python yourself — building beats watching.