Is it possible to get the exit code of the previous command that as run on the shell in python?
I want to write a script that will return the same error code that is currently set (assuming the python command is successful). It would be the equivalent of doing something like this in bash:
#!/bin/bash
err=$?
# Do something...
exit $err
I would like to avoid passing it in as an argument, if possible. For example:
python script.py $?