Abstract Method

A method with no logic
It’s a rule only – every subclass must write its own version

Bank Analogy:

Think of the withdrawal process.

  • Savings Account → withdraw only if balance is available

  • Current Account → allow overdraft

  • Digital Wallet → maybe allow cashback or limits

So, the main account says:

from abc import ABC, abstractmethod

class BankAccount(ABC):
    @abstractmethod
    def withdraw(self, amount):  # abstract method
        pass

It’s like saying:
"Every type of account must write their own withdraw logic."

Only works in abstract class


So, How Do You Know It's Abstract?

@abstractmethod
def withdraw(self, amount):
    pass
  • That @abstractmethod decorator is the signal

  • It means → no logic, just a rule

Updated on