Should I always specify an exception type in `except` statements?

前端 未结 7 1329
广开言路
广开言路 2020-11-22 15:33

When using PyCharm IDE the use of except: without an exception type triggers a reminder from the IDE that this exception clause is Too broad.

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 15:57

    You will also catch e.g. Control-C with that, so don't do it unless you "throw" it again. However, in that case you should rather use "finally".

提交回复
热议问题