1

I'm writing a python (v. 3.9) program intended to be run in interactive mode. Program needs an argument to run properly. So, I try to check if the argument is present or if it is not in order to continue with the following lines:

import sys

if (len(sys.argv) >= 2):
    prefix=sys.argv[1]
else : 
    print(" Usage: python -i my_program.py one_argument")
    quit()

But it just shows an error message and does not exit. I have tried also exit() sys.exit() type(quit()) (in place of quit()) with the same result.

Is it possible to program in advance quitting in interactive mode?

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.