Coding⏱️ 2 min read📅 2026-05-31

How to Fix: Why do I get "TypeError: Missing 1 required positional argument: 'self'"?

TypeError: Missing 1 required positional argument: 'self'

Quick Answer: In Python, the first parameter in a method is automatically passed by the interpreter and is called 'self'. You need to include 'self' as the first parameter in your methods.

The error message indicates that the method `getPumps` is missing the required positional argument `'self'`, which refers to the instance of the class. This is because in Python, when you define a method inside a class, it automatically receives an implicit parameter named `self`. However, when you call a method directly on an object without using the dot notation (`obj.method()`), Python does not pass the instance as an argument.

🛠️ Step-by-Step Verified Fixes

Method 1: Accessing an Instance Method Directly

  1. Step 1: Create an instance of the `Pump` class using the dot notation, for example: p = Pump()

Method 2: Calling a Class Method Using the Dot Notation

  1. Step 1: Call the `getPumps` method on an instance of the `Pump` class, for example: p = Pump(); p.getPumps()

✨ Wrapping Up

By following these steps, you should be able to resolve the `TypeError: Missing 1 required positional argument: 'self'` error when accessing an instance method directly.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions