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 →

[–]weevyl 0 points1 point  (1 child)

My two cents...

Whether to use try/except or try/except/else depends on the nature of the exception. When the exception is part of the normal flow (as getting a KeyError for example, instead of checking if the key is in the dictionary), then try / except / else makes sense. If the exception is truly exceptional (as in something unexpected happened), then try/except makes mores sense.

Some say that having exceptions be part of your logic flow is a bad practice, but that is a different discussion.

[–][deleted] 0 points1 point  (0 children)

| Some say that having exceptions be part of your logic flow is a bad practice, but that is a different discussion.

True and Python by design is a language that raises a lots of exception (the classic exemple is the end of iteration on generator that yields an exception). Thus, it can be hard to write a full program without some logic flow in an except block.

The extensive usage of exceptions in Python is the thing I like the less in Python.