On 01/03/2022 22:25, Chris Angelico wrote:
class MyBreak(Exception):
pass
try:
do_this()
if condition: raise MyBreak
do_that()
if condition: raise MyBreak
do_next_step()
if condition: raise MyBreak
do_last_step()
except MyBreak:
pass
It doesn't feel right to me to use exceptions purely to direct control
flow. YMMV.
As I see it, the original meaning of an exception (in whatever language)
is "something unexpected has happened" or "something has gone wrong".
While it is too narrow to insist that they only be used with that
meaning, this use doesn't feel like a good fit.
Rob Cliffe
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/JUJJ5AI627S5JUUYOS7TQ6BZBTA4IZTZ/
Code of Conduct: http://python.org/psf/codeofconduct/