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

Eliminate dependency on sys module in "if main" snippet #429

Merged
merged 1 commit into from
Oct 25, 2016
Merged

Eliminate dependency on sys module in "if main" snippet #429

merged 1 commit into from
Oct 25, 2016

Conversation

gandhis1
Copy link
Contributor

@gandhis1 gandhis1 commented Oct 25, 2016

Justification:

  • Putting an import within the "if main" seems unconventional, most linters will ask you to move it to the top of the module, typically leads to one manually copying the import to the top of the module - it is no longer a self-contained snippet
  • It doesn't seem that common of a convention for instance here in the official Python docs, or here from a popular question on StackOverflow
  • There is a very old blog post by Guido about this, which is similar to the current implementation, but is attempting to remedy what probably is a non-issue - one calling sys.exit() in the main() function
  • For simplicity purposes, and cleanest code, I think the sys module dependency and associated exit() call should be removed

@DonJayamanne DonJayamanne merged commit dc98883 into DonJayamanne:master Oct 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants