Inhaltsverzeichnis

Objekt-Methoden

class static_test:

    my_string = "Peter"

    def ausgabe(self):
        print("Ausgabe", self.my_string)

    def caller(self):
        self.ausgabe()

a = static_test()
a.ausgabe()

Static Method

class static_test:

    my_string = "Peter"
    @staticmethod
    def ausgabe():
        print("Ausgabe")

    def caller(self):
        self.ausgabe()

static_test.ausgabe()
a = static_test()
a.ausgabe()

Class Method

class static_test:

    my_string = "Peter"
    @classmethod
    def ausgabe(cls):
        print("Ausgabe", cls.my_string)

    def caller(self):
        self.ausgabe()

static_test.ausgabe()
a = static_test()
a.ausgabe()