WedWonder: Scripts and Modules

Chris Angelico rosuav at gmail.com
Thu Sep 12 05:47:34 EDT 2019


On Thu, Sep 12, 2019 at 6:57 PM Barry Scott <barry at barrys-emacs.org> wrote:
> As scripts become more complex having it run on import might make debugging harder
> and prevents reuse.
>
> For example I will import a script at the REPL and examine it and call function in it to
> help me understand and fix problems.  Having a __name__ == '__main__' is important
> to allow this.

If the script is fairly simple, and hasn't been built to operate as a
module, it's often effective enough to just run "python3 -i
scriptname.py" and have it do its stuff and immediately drop to REPL.

ChrisA



More information about the Python-list mailing list