Search Results

Search found 1 results on 1 pages for 'user2131316'.

Page 1/1 | 1 

  • how could it works if function is called before it is defined in python?

    - by user2131316
    I was wondering what does if __name__ == "__main__": really do in python, I have the following code in python3: def main(): test(); def test(): print("hello world " + __name__); if __name__ == "__main__": main(); we know that we have to declare a function before we use it, so function call inside of if part works fine, the main() is defined before it is called inside of if statement, but what about the test() function, it is defined after it is called and there is no errors: def main(): test(); def test(): print("hello world " + __name__); so how could it works if the test() function is defined after it is called?

    Read the article

1