This comment caught my attention:
https://github.com/scikit-agent/scikit-agent/pull/19#discussion_r2112768829
use of
continuefor control flow is discouraged.
Is it?
I see Guido cautions against using continue in a finally block in https://peps.python.org/pep-0008/:
Use of the flow control statements
return/break/continuewithin the finally suite of atry...finally, where the flow control statement would jump outside the finally suite, is discouraged. This is because such statements will implicitly cancel any active exception that is propagating through the finally suite…
I haven’t found any style guides discouraging it in general though. Google’s doesn’t mention it: https://google.github.io/styleguide/pyguide.html. Glancing (and ⌘-F-ing) through https://docs.python-guide.org/writing/style/, I don’t see anything either.
Do you have a strong opinion on this?
Here’s a non-definitive discussion on Stack Overflow: https://stackoverflow.com/questions/13692293/is-continue-bad-practice
I appreciate the Doug Crawford quote but don’t find this article convincing myself either: https://www.teamten.com/lawrence/programming/avoid-continue.html.
If a reviewer asked me to take it out or if the project style guide mandated it (especially if given a rationale beyond general practice… which it’s not?), I’d be happy to try to oblige, but I think I’ll continue using it in my own stuff. Eh, eh.
Leave a Reply