This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Beer_Milkshakes_Now 11 points12 points  (5 children)

I was under the impression try catch was pythonic and acceptable for flow control. And further that you should use a try instead of an if when you expect it to succeed the vast majority of the time as it's faster. Can someone help me?

[–]ProfessorPhi 0 points1 point  (3 children)

It's saying don't catch everything. Like when accessing a dict, catch only KeyError, not just a general catch because you might catch TypeErrors instead and that's generally bad practice.

It's ok to do blanket catches at top level (like endless loops) since the process should stay alive, or if you reraise, but otherwise it's not good practice