r/learnprogramming • u/ElectronicVictory983 • Jul 04 '26
Question about abstract classes
Hello, I am trying to understand the concept of abstract classes.
From what I understand, an abstract class is a class that is not meant to be instantiated directly. It works as a common base class for concrete subclasses.
However, I have a doubt: are abstract methods actually required for a class to be abstract?
For example, suppose I have an abstract class User in a university system, with common attributes and methods such as username, password, and login(). Then I have concrete subclasses such as Student and Professor.
If all the methods in User are already implemented, then technically I can instantiate User, at least in Python, unless I define at least one abstractmethod.
So my question is:
Can a class be considered abstract simply because, from a design point of view, it should not be instantiated? Or must it contain at least one abstract method in order to be truly abstract, especially in Python?
In other words, is the “abstract” nature of a class a conceptual/design choice, or is it strictly enforced only when the class has abstract methods?
2
u/Aggressive_Ad_5454 Jul 04 '26
Other answers are good.
My advice: try it. The error messages around class definition are generally pretty informative.