I'm going to note here that it is perfectly reasonable to use Python as a "scripting language" -- to, you know, write scripts.
And when I'm writing scripts, I make heavy use of the global namespace :-) Granted, if it's really a quick and dirty script, I'll not bother with if __name__ == "__main__" at all, but there is a middle ground, where I do. There's no need to restrict Python to be more structured in this manner. -CHB On Thu, May 28, 2020 at 12:52 PM David Mertz <[email protected]> wrote: > On Thu, May 28, 2020, 3:06 PM Chris Angelico <[email protected]> wrote: > >> 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. >> > > I take back my comment. I think I may have used the multiple __main__ > blocks occasionally, for reasons Chris notes. Like I want something > configured BEFORE a function is defined (maybe a global that only makes > sense when run as script). > > However, I haven't done it for a long while. I think when I was younger I > didn't value encapsulation sufficiently. That said, I don't want the > capability to change. There are lots of things I don't do stylistically, > but I don't want striken from the language. > > > _______________________________________________ > 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/FPDFDFM66BZSHPYM3ZNYHEMZ4PTR5T3L/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- Christopher Barker, PhD Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
_______________________________________________ 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/QCVJTAFY5QDAAMAOOA3DQKAHWRK5ZIV5/ Code of Conduct: http://python.org/psf/codeofconduct/
