Using if __name__ == “__main__” for Main Entry Point in Python


Control script execution when running or importing.

Source Code

def main():
    print("This is a script.")

if __name__ == "__main__":
    main()
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments