Skip to content

Instantly share code, notes, and snippets.

@tkmru
Created December 15, 2013 19:32
Show Gist options
  • Save tkmru/7977075 to your computer and use it in GitHub Desktop.
Save tkmru/7977075 to your computer and use it in GitHub Desktop.
if "try sentence" use "else", code detect error strictly.
# bad case
try:
do_something()
log.debug(u"complete") # if error raise here, code can't detect error.
except:
log.debug(u"error")
# good case
try:
do_something()
except:
log.debug(u"error")
else:
log.debug(u"complete")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment