EbonJaeger Use -i
.
From man python
:
-i When a script is passed as first argument or the -c option is
used, enter interactive mode after executing the script or the
command. It does not read the $PYTHONSTARTUP file. This can be
useful to inspect global variables or a stack trace when a
script raises an exception.
Also, it's good practice to use #!/usr/bin/env python3
instead of #!/usr/bin/python3
for portability. That way it uses whatever python3
the user so desires per their $PATH
settings.
Putting it all together,
#!/usr/bin/env -S python3 -i
# Your script here...
results in your script being executed, and then the interpreter left open.
Note that you'll have to run this Python script from a terminal already. If you want to double click on a file to open a terminal and run that script, it depends on your terminal and your file manager.