[Solved] Why would the top print() statement print to the console after a later line of code


It’s because you are importing one before printing “top level two.py”. if one.py looks like this:

print("top level one.py")

def func():
    #do something 

if __name__ == '__main__':
    print("one.py being run directly")

else:
    print("one.py has been imported")

and with the two.py code above, then one.py is run first, when it is imported.
Because one is running first, then its print statements will happen before the prints in two, and so they will show up first.

2

solved Why would the top print() statement print to the console after a later line of code