Order of execution and style of coding in Python

Posted by Jason on Stack Overflow See other posts from Stack Overflow or by Jason
Published on 2010-06-06T17:09:07Z Indexed on 2010/06/06 17:12 UTC
Read the original article Hit count: 147

Filed under:

Hi guys.

I am new to Python so please don't flame me if the question is too basic :)

I have read that Python is executed from top - to - bottom.

If this is the case, why do programs go like this:

def func2(): 

def func1(): #call func2()

def func() #call func1()

if __name__ == '__main__': call func()

So from what I have seen, the main function goes at last and the other functions are stacked on top of it.

Am I wrong in saying this? If no, why isn't the main function or the function definitions written from top to bottom?

© Stack Overflow or respective owner

Related posts about python