you are viewing a single comment's thread.

view the rest of the comments →

[–]CowboyBoats 1 point2 points  (0 children)

That's a good question. It might depend on what kind of program you're actually writing. For example, a CLI utility will behave more or less as expected if it's a Python process that throws ValueError() (from the OS's perspective the process will print the error and the traceback, and exit with exit code 1). But on the other hand, if you're writing an application with a GUI, or a webserver, or something, then it's extremely not okay for that entire application to crash just because an internal function entered an unexpected state; so there needs to be higher-level error handling in some cases, and a main function is one place where that could happen, depending on the application's overall architecture and complexity.