
On Fri, May 29, 2020 at 2:32 AM David Mertz <mertz@gnosis.cx> wrote:
On Thu, May 28, 2020, 12:17 PM <jdveiga@gmail.com> wrote:
The OP is proposing as a possibility: "we could require user to have only one if __name__ == '__main__':". In that case, functionality will be reduced, won't it?
I don't support the proposal. However, I've also never written a script with multiple 'if __name__ == __main__' lines, and I think if I saw one I'd complain in code review.
It's hard for me to imagine how multiple entry point to a script can be a good thing.
There aren't multiple entry points, though. There would be multiple blocks of code that are skipped if the module is imported, but executed if it's run as a script. Remember, Python code is NOT declarative. That 'def' statement is an actual executable bit of code. ChrisA