I think I found a recipe for a new Python file:
def ...(): ... def ...(): ... def main(): ... ... if __name__ == '__main__': main()
Instead of putting everything in
main() plainly under the
Why ? I have a list:
You should not be able to create and mutate global vars at will and during runtime! Under the
ifstatement, any var declared will be global.
It just harder for IDE to help us auto-suggesting the code. The IDE will not know whether a var or a function declared under the
ifstatement will be available at the runtime or not. This is a bad thing because the auto-suggestion list will contain a bunch of choices that doesn't work.
And, it's also easier for unit-testing. Instead of indirectly running a
.pyfile, we can direct this into just using a function call.