0

I have a simple script that i use to invoke another script, which succeeds returns an id. Atm the most convenient method i see is as follows.

#scriptA.py
x =doOperations(x=1231)
exit(x)

.

#scriptB.py
result = procScriptA.returncode()

Is there any harm in doing that, i kinda have the feeling that i am exploiting the exit functionality, but is there any other way without outputting to stderr or stdout?

I read this already: Best way to return a value from a python script

1 Answer 1

1

On many operating systems, sys.exit() can only return integers between 0 and 127. It's primarily intended for signalling whether the command completed successfully (by returning 0) or encountered an error (by returning another value), not for passing back a numerical result.

Use standard output to return results.

Sign up to request clarification or add additional context in comments.

1 Comment

if i use a standardoutput, i can't use any print statement before that, as it will be in the output too

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.