It's generally preferred to have a main function which is then "registered" to run only if the program is executed directly (over putting code straight into the uppermost scope to run unconditionally when the module is invoked/loaded).
This is not only a Python convention but also makes the programs functionality/sub-modules available for people to import without forcing an execution of the entire thing.
It's generally preferred to have a main function which is then "registered" to run only if the program is executed directly (over putting code straight into the uppermost scope to run unconditionally when the module is invoked/loaded).
This is not only a Python convention but also makes the programs functionality/sub-modules available for people to import without forcing an execution of the entire thing.