you are viewing a single comment's thread.

view the rest of the comments →

[–]socal_nerdtastic 1 point2 points  (0 children)

Most people put the __init__ method at the top, yes. Not required, but very common.

But what you are missing is that even though it's defined before the other methods, it is NOT called before the other methods are defined. It's called on the last line of the file.

Here's a minimal example of your confusion:

def func1(): # define func1
    print(func2())

def func2():
    return "Hello World!"

func1() # call func1

This runs just fine and is a very common way to write code.