Are bad try / catch attachments statements?

My business right now:

try:
  try:
    condition
  catch

  try:
    condition
  catch

catch
 major failure

Is it bad to have such code? Too much noise or some consequences of this?

+5
source share
2 answers

I wouldn’t just cut off the verdict and demand “it's bad,” because sometimes you may need it. Python sometimes deliberately throws exceptions instead of letting you ask (is that ...?) [EAFP motto], and in some cases, nesting try/catchis useful when it makes sense with a logical code stream.

, . , - , , .

+2

, ( except, catch). , .

, , Exception , - (, KeyError). .

+3

All Articles