Why assert is not largely used?

后端 未结 4 1168
情深已故
情深已故 2021-01-31 13:13

I found that Python\'s assert statement is a good way to catch situations that should never happen. And it can be removed by Python optimization when the code is trusted to be c

4条回答
  •  一向
    一向 (楼主)
    2021-01-31 14:10

    As per my experience, asserts are majorly used in development phase of a program-to check the user defined inputs. asserts are not really needed to catch programming errors. Python itself is very well capable of trapping genuine programming errors like ZeroDivisionError, TypeError or so.

提交回复
热议问题