Static-Decorator

Sat 17 May 2025

title: "Static Decorator" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


class Example:
    name = "Example"

    @staticmethod
    def static():
        print("%s static() called" % Example.name)
class Offspring1(Example):
    name = "Offspring1"
class Offspring2(Example):
    name = "Offspring2"

    @staticmethod
    def static():
        print("%s static() called" % Offspring2.name)
Example.static()
Example static() called
Offspring1.static()
Example static() called
Offspring2.static()
Offspring2 static() called


Score: 5

Category: basics