def main(): # this is first, it is defined but doesn't do anything until called print("This is main") # this is eight class user_input(): # this is second, it is defined but doesn't do anything until called print("This is class") this is fourth print(user_input()) # this is third and fifth and actions straight away as its a statement and a function call in the global space if __name__ == "__main__": # this is sixth and actions straight away as its a conditional statement in the global space main() # this is seventh and actions straight away as its a function call in the global space
The above is actually wrong, the
print("This is class")
happens when the class is defined so is actually thirdYou can use this link to visualise code execution