• 0 Posts
  • 127 Comments
Joined 5 months ago
cake
Cake day: January 16th, 2024

help-circle

  • This is bad practice.

    More accurately it should look something like this:

    # Load sys library for exiting with status code
    import sys
    
    def sayHelloWorld(outPhrase: str="Hello World"):
        # Main function, print a phrase and return NoneType
        print(outPhrase)
        return None
    
    if __name__=="__main__":
        # Provide output and exit cleanly when run from shell
        sayHelloWorld()
        sys.exit(0)
    else:
        # Exit with rc!=0 when not run from shell
        sys.exit(1)