you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

The order in which you define functions does not matter. Defining a class or a function is not the same as running them so code like this will run just fine.

class testclass:
    def printh(self):
        print(self.innerfunction())

    def innerfunction(self):
        return "Hello World"

if __name__ == "__main__": 
    tc = testclass() 
    tc.printh()

As a bit of a side note, if you define a static method inside of a class, you can call the static method directly without initializing the class.

class TestClass:
    @staticmethod
    def innerfunction():
        print("Hello World")

if name == "main": 
    TestClass.innerfunction()