How to prevent python IDLE from restarting when running new script

雨燕双飞 提交于 2019-12-04 17:21:25
Treebasher

What about writing a master script that makes calls to execfile("other_script.py") (in Python 2) or exec(open("other_script.py").read()) (Python 3)? Then just run the master script in IDLE. You will probably need shebang lines and (possibly) appropriate execute permissions for each script.

See this thread as I derived my answer from some stuff discussed there.

Another option would be to automate your "typing things into the shell" with a shell script (bash, batch, sh, whatever shell you are using on your system).

Realistically though, like others have said, it doesn't really seem like there is much benefit in modularizing this task by splitting it up into separate files. Why not just create a Python program that has all the functions you need, and then calls them as appropriate?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!