osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

WedWonder: Scripts and Modules


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