Understanding the if __name__ == '__main__' Syntax
Syntax:
def run():
print("the process is starting")
def shut_down():
print("process is shutting down")
def email_admin():
print("Violation noted. Emailing admin...")
# Starting point of the application
if __name__ == '__main__':
email_admin() # First task running
shut_down() # Second task runningIt can also be imported:
from process import *
run()
shut_down()Understanding the syntax
Last updated