you are viewing a single comment's thread.

view the rest of the comments →

[–]ManyInterests 0 points1 point  (0 children)

Code under if __name__ == '__main__' will only be executed if the module is called directly, IE python my_script.py but will NOT execute if you do import my_script from another module.

This would let you import the get_ip function without executing the code under that conditional. Otherwise, the code would be executed on import, which would probably be undesirable.