i have a python module which i compile to an EXE (using Py2EXE).

this EXE will be called from another program which was created in C++.

my Q is, how can i return an error status from my PY exe to the calling program. is there anyway i can alert the calling to an error?

thanx for your interest!

8 Years
Discussion Span
Last Post by sab73

If the python program quits with an error the return code is 1. If it successfully runs the return code is 0.

You can alternately specify your own return codes using sys.exit(return_code_value) at specific exit points of your code.


ah, thanx for the info. i came across sys.exit() but didnt know then what it did.

i'll try this out.


hi, this works. :)

just out of curiosity, thru my PyScripter, sys.exit() does not actually exit the codes. it will continue on. for compiled EXE it will exit whne sys.exit() is executed.

wld you know the reason to this?


I'm sure it has something to do with your PyScripter.

Try running the code from the console. It could just be that PyScripter dumps you into a shell after your program has completed... But I've never used that IDE, so I'm not sure.


yeah, pretty sure its PyScripter.

thanx for your help. :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.