Skip to content

Conversation

@wm75
Copy link

@wm75 wm75 commented Jul 1, 2020

No description provided.

@wm75
Copy link
Author

wm75 commented Jul 1, 2020

In general, I wouldn't handle errors that way (printing and exiting), but rather raise a custom Python exception.
This way you'd keep the traceback, which is so much better for fixing bugs and diagnosing user bug reports!

end = int(end)
except Exception:
print('User Error: invalid start/end coordinate(s)')
except ValueError:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also note that the try/except won't catch negative values, if that's the intention.

@lgtm-com
Copy link

lgtm-com bot commented Jul 1, 2020

This pull request introduces 1 alert and fixes 2 when merging 77e91e7 into 52fd2a1 - view on LGTM.com

new alerts:

  • 1 for Syntax error

fixed alerts:

  • 2 for Unreachable code

if tab is None:
tab = 1
else:
if int(tab) in [1, 2, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15, 16, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 33]:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a range here!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and do the int conversion outside of the function to avoid the duplicated action

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.

1 participant