You're looking for calls to sys.exit(...) (exit(...) calls sys.exit(...)) in the script. The argument to that method is returned to the environment as the exit code.
It's fairly likely that the script is never calling the exit(...) method, and that 0 is the default exit code.
You're looking for calls to sys.exit(...) (exit(...) calls sys.exit(...)) in the script. The argument to that method is returned to the environment as the exit code.
It's fairly likely that the script is never calling the exit(...) method, and that 0 is the default exit code.
From the documentation for sys.exit:
The optional argument arg can be an integer giving the exit status (defaulting to zero), or another type of object. If it is an integer, zero is considered “successful termination” and any nonzero value is considered “abnormal termination” by shells and the like. Most systems require it to be in the range 0-127, and produce undefined results otherwise. Some systems have a convention for assigning specific meanings to specific exit codes, but these are generally underdeveloped; Unix programs generally use 2 for command line syntax errors and 1 for all other kind of errors.
One example where exit codes are used are in shell scripts. In Bash you can check the special variable $? for the last exit status:
me@mini:~$ python -c ""; echo $?
0
me@mini:~$ python -c "import sys; sys.exit(0)"; echo $?
0
me@mini:~$ python -c "import sys; sys.exit(43)"; echo $?
43
Personally I try to use the exit codes I find in /usr/include/asm-generic/errno.h (on a Linux system), but I don't know if this is the right thing to do.
Return codes - Is there a list of them?
unix - Python exit codes - Stack Overflow
KeyboardInterrupt and SystemExit in exception groups should be considered for Python's exit code - Ideas - Discussions on Python.org
Pycharm Exit Code
This code looks like a Access violation error. Without any code we can't help you, but most of the time you tried to read an incorrect part of a file, maybe the GeoJSON file is corrupted or you need to use the correct encoding.
More on reddit.comVideos
I was using subprocess.run and needed to understand the return codes. Problem is I haven't been able to find a list of them. Python docs seem to be of little help as far as I can find.
Does anyone know of a list and maybe a range of return codes for other functions as well?
Much appreciated.
Edit: Mystery \ Misunderstanding SOLVED... Thanks.
As stated, mostly the error codes come from the executed script and sys.exit().
The example with a non-existing file as an argument to the interpreter fall in a different category. Though it's stated nowhere I would guess, that these exit codes are the "standard" Linux error codes. There is a module called errno that provides these error numbers (the exit codes come from linux/include/errno.h.
I.e.: errno.ENOENT (stands for for "No such file or directory") has the number 2 which coincides with your example.
The Python manual states this regarding its exit codes:
Some systems have a convention for assigning specific meanings to specific exit codes, but these are generally underdeveloped; Unix programs generally use 2 for command line syntax errors and 1 for all other kind of errors.
So, since you specified thisfiledoesntexist.py as a command line argument, you get a return code of 2 (assuming the file does not, in fact, exist. In that case I'd recommend renaming it to thisfiledoesexist.py. ;) )
Other that such parsing errors, the return code is determined by the Python program run. 0 is returned unless you specify another exit code with sys.exit. Python itself does not interfere.