Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run python script without terminating at the end

Tags:

python

Is there a command line switch to carry out the script specified without terminating the process at the end?

Windows' cmd.exe for example has the /K switch.

like image 912
iTayb Avatar asked Aug 01 '26 06:08

iTayb


2 Answers

As stated on python's manual:

-i switch

When a script is passed as first argument or the -c option is used, enter interactive mode after executing the script.

like image 63
iTayb Avatar answered Aug 03 '26 20:08

iTayb


One option is to add code in your script to drop into an interactive prompt. See this answer.

import code
code.interact(local=locals())
like image 23
snapshoe Avatar answered Aug 03 '26 19:08

snapshoe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!