Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[best-practices-programming] python: quit() vs sys.exit(1) #43

Open
jgvictores opened this issue Dec 21, 2019 · 2 comments
Open

[best-practices-programming] python: quit() vs sys.exit(1) #43

jgvictores opened this issue Dec 21, 2019 · 2 comments

Comments

@jgvictores
Copy link
Member

[best-practices-programming] python: quit() vs sys.exit(1)

Just putting here to document. Not a serious issue, just in the light of roboticslab-uc3m/yarp-devices@3c1f7f3 where both were being used. Could not find similar issue in https://github.com/roboticslab-uc3m/questions-and-answers.

@PeterBowman
Copy link
Member

PeterBowman commented Dec 21, 2019

See also commit description at roboticslab-uc3m/kinematics-dynamics@127a768 and https://stackoverflow.com/a/19747562.

@jgvictores
Copy link
Member Author

Yup, I agree with my past self that raise SystemExit saves you from import sys. A few notes:

  • Both exit(1) and raise SystemExit(1) are valid syntax.
  • There is a small goodie in exit: "exit("Here is why the program failed"), which prints the error message and exits with return status 1." (via Jasha at mentioned SO answer).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants