Is python exception handling more efficient than PHP and/or other languages?

前端 未结 6 998
遥遥无期
遥遥无期 2021-01-03 21:32

I have it drilled into my head that (at least in PHP) it is badbadmojo to use try... catch blocks for flow control. What I\'ve learned is to use them only to h

6条回答
  •  情书的邮戳
    2021-01-03 21:57

    I don't believe that the EAFP encourages the use of exceptions for flow control. Rather, it tells us that we needn't bother checking for the existence of a particular key in a dictionary or property of an object before we reference it.

    Throwing exceptions as an alternative to if statements or having correct while statements or instead of using break or continue inside of a loop does not fall under that category. That's lazy, error-prone progamming and it should be avoided.

提交回复
热议问题