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

Community
  • 1
  • 1
user1767754
  • 21,126
  • 14
  • 125
  • 152

1 Answers1

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.