re: What's the use of if __name__ == '__main__': in Python? VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Hey Luca. Thanks for taking the time to help me out. Nice explanation. It also indicates the starting point of the script when executing script_...
 

Hey Kinyanjui, you're absolutely right, the line does not have to be there.

If you want to use your script in two ways, execute it on its own and import it in another script, that's when you need to include if __name__ == '__main__':. Otherwise you don't need it.

code of conduct - report abuse