On 15/06/22 7:49 am, Chris Angelico wrote:
If it does need to be used as a module as well as a script, sure. But (a) not everything does, and (b) even then, you don't need a main()
I think this is very much a matter of taste. Personally I find it tidier to put the top level code in a function, because it ties it together visually and lets me have locals that are properly local. If the file is only ever used as a script, I just put an unconditional call to the main function at the bottom. -- Greg -- https://mail.python.org/mailman/listinfo/python-list