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

前端 未结 7 1312
广开言路
广开言路 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 16:04

    Always specify the exception type, there are many types you don't want to catch, like SyntaxError, KeyboardInterrupt, MemoryError etc.

提交回复
热议问题