0

I want to quit interpreter when -i is passed in. eg

> python -i test.py
yeah
SystemExit
>>>

I want to quit interpreter. my test.py

import sys
print 'yeah'
sys.tracebacklimit = 0
sys.exit()

I have tried exit() and quit(), but I am still in the interpreter. The reason I want to do this is because I have a script from mayapy( autodesk maya python interpreter ), which launches like this mayapy -i myscript.py [args], I want to quit interpreter when --help is passed as argument, but it always stays in interpreter because -i is passed in.

Is there a way to have the same effect as ctrl+d ?

1 Answer 1

2

You can invoke the os._exit call.

import os
os._exit(0)
Sign up to request clarification or add additional context in comments.

Comments

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.