I would like my Python script to pause before exiting using something similar to:
raw_input(\"Press enter to close.\")
but
Although this isn't a very good solution, it does work (in windows at least).
You could create a batch file with the following contents:
@echo off
for %%x in (%cmdcmdline%) do if /i "%%~x"=="/c" set DOUBLECLICKED=1
start
if defined DOUBLECLICKED pause
If you want to be able to do this with a single file, you could try the following:
@echo off
setlocal EnableDelayedExpansion
set LF=^
:: The 2 empty lines are necessary
for %%x in (%cmdcmdline%) do if /i "%%~x"=="/c" set DOUBLECLICKED=1
echo print("first line of python script") %LF% print("second and so on") > %temp%/pyscript.py
start /wait console_title pyscript.py
del %temp%/pyscript.py
if defined DOUBLECLICKED pause
Batch code from: Pausing a batch file when double-clicked but not when run from a console window? Multi-line in batch from: DOS: Working with multi-line strings