Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

32
  • 7
    dont use exceptions for flow control Commented Dec 13, 2022 at 14:01
  • 2
    Can methodB(object) throw an exception? If it can, you may end up calling it twice in your first function, but only once in your second function. Maybe your try/except should be inside the if suitedForA(object):? Commented Dec 13, 2022 at 14:57
  • 1
    Can you edit your question to include more details? These generic names make it difficult to answer your question. @Kevin brings up a good point about possibly calling methodB twice. Depending on what these functions do, this might be OK, but it also might be a bug. Commented Dec 13, 2022 at 15:36
  • 1
    @Ewan Using exceptions for control flow has been considered acceptable in Python development for quite some time. Commented Dec 13, 2022 at 16:52
  • 1
    @Ewan What's your python experience exactly? The top answer here explains why it's basically unavoidable. Please show some reference for your claim. Commented Dec 13, 2022 at 18:35