About Overriding Class Methods in Python

In Python, you cannot directly override class methods with super(), but you can do this instead:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
class Simple(object):
    @classmethod
    def get_feature_name(cls):
        return "The Feature"

class Magical(Simple):
    @classmethod
    def get_feature_name(cls):
        value = Simple.get_feature_name()
        return f"✨✨✨ {value} ✨✨✨"

print(Simple.get_feature_name())
print(Magical.get_feature_name())

Tips and Tricks Programming Python 3