def __main__() at the end of the file will be something nice to have. It’s much easier to explain to new students than if __name__ == __main__: main(). Can we import this new __main__ function from another file and use it in another file? Maybe it should be disallowed to remove confusion and conflict or only allowed if it was imported as another name (e.g. from file_b import __main__ as main_b)
It would take optional arguments like number of command line arguments and the command line arguments as a list similar to C and C++: def __main__(argc: int, argv: list[str]): … Abdulla Sent from my iPhone > On 2 Oct 2021, at 10:43 AM, Chris Angelico <[email protected]> wrote: > > On Sat, Oct 2, 2021 at 3:15 PM Jonathan Crall <[email protected]> wrote: >> >> That's effectively every module I write. I don't think that's uncommon or >> bad practice. >> > > Interesting. Why is that? > > ChrisA > _______________________________________________ > Python-ideas mailing list -- [email protected] > To unsubscribe send an email to [email protected] > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/[email protected]/message/6URF34QLGEYYKYZZR3W5EV7MTQJS2SY5/ > Code of Conduct: http://python.org/psf/codeofconduct/ _______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/6W4C3MXJ3M7OZ7GD5JBWNPFBSAH2VCRM/ Code of Conduct: http://python.org/psf/codeofconduct/
