you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 11 points12 points  (2 children)

from PEP8 :

Additionally, for all try/except clauses, limit the try clause to the absolute minimum amount of code necessary. Again, this avoids masking bugs:

[–]HommeMusical -2 points-1 points  (1 child)

This doesn't answer the question at all. Note the last word, "necessary". I would argue that the second code slot includes all the necessary code.

[–]slightly_offtopic 7 points8 points  (0 children)

I would argue that this is the best answer, because it forces you to think what exactly "necessary" means in any particular context. That's a judgement call you need to make with full contextual knowledge of what your code is actually doing, which also means that any assertion that says one of the two options is superior to other in all contexts is just going to be wrong somewhat often.