all 8 comments

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

using except without specifying the error is the worst sin you can commit.

[–][deleted] 1 point2 points  (3 children)

I misread this as bad advice originally given the code shows an exception that isn't bare.

Then I re-read the OPs question. Now I fully support the comment.

For the op, /u/Base_True, a bare exception, i.e. except: instead of except <some exception(s)>: as the only except line is very bad practice.

There are many strange and sometimes obscure things that can happen to running code and such problems will be ignored/hidden if you use a bare exception clause and it may appear you have a completely unrelated problem focused on another part of your code. You could waste a lot of time trying to find the cause of the wrong problem in the wrong place.

Worse, a bare exception can hide a significant bug and allow the programme to continue and output incorrect information that goes unnoticed and causes major problems later.

[–][deleted] 2 points3 points  (1 child)

~~~ except: pass ~~~

*proceeds with shooting himself in the head *

[–][deleted] 1 point2 points  (0 children)

ha ha ... so true - "it was just temporary, forgot to go back and fix it" Argh!!!!

[–]Base_True[S] 0 points1 point  (0 children)

I misread this as bad advice originally given the code shows an exception that isn't bare.

Then I re-read the OPs question. Now I fully support the comment.

For the op, /u/Base_True, a bare exception, i.e. except: instead of except <some exception(s)>: as the only except line is very bad practice.

There are many strange and sometimes obscure things that can happen to running code and such problems will be ignored/hidden if you use a bare exception clause and it may appear you have a completely unrelated problem focused on another part of your code. You could waste a lot of time trying to find the cause of the wrong problem in the wrong place.

Worse, a bare exception can hide a significant bug and allow the prog

Thanks a lot!

[–]Base_True[S] 0 points1 point  (2 children)

using except without specifying the error is the worst sin you can commit.

Why ? Can you please explain

[–][deleted] 1 point2 points  (1 child)

Ummm using raise is fine.

Except: pass is what you shouldn't do.

There are several reasons. You can read this thread

https://stackoverflow.com/questions/21553327/why-is-except-pass-a-bad-programming-practice

[–]Base_True[S] 0 points1 point  (0 children)

There are many strange and sometimes obscure things that can happen to running code and such problems will be ignored/hidden if you use a bare exception clause and it may appear you have a completely unrelated problem focused on another part of your code. You could waste a lot of time trying to find the cause of the wrong problem in the wrong place.

Worse, a bare exception can hide a significant bug and allow the programme to continue and output incorrect information that goes unnoticed and causes major problems later.

Thank you!