Background
I am attempting to create an interpreter for a toy programming language. I built the interpreter with ANTLR4 + Python. Then, I compiled the interpreter using Nuitka and bundled it using Inno Setup. After installing with Inno Setup, the executable can be invoked in two ways:
- Invoking the name from the terminal. (Running 
mylang myfile.code) - Double-click an associated file. (Clicking 
myfile.codein the explorer) 
Issue
When I run the executable by clicking the associated file, a terminal is spawned, but then it immediately disappears when the myfile.code program finishes, giving me no time to read the output. I found this SO question which lead me to os.system("pause"). However, when this makes my program pause when it is invoked from the terminal normally, which is unnecessary and unwanted.
Question
Is there a way to detect which way the program was invoked so I can pause only when it was run from clicking an associated file?