About 50 results
Open links in new tab
  1. Best Practices for Python Exceptions? - Stack Overflow

    97 Robust exception handling (in Python) - a "best practices for Python exceptions" blog post I wrote a while ago. You may find it useful. Some key points from the blog: Never use exceptions for flow …

  2. python - How can I catch multiple exceptions in one line? (in the ...

    76 From Python documentation -> 8.3 Handling Exceptions: A try statement may have more than one except clause, to specify handlers for different exceptions. At most one handler will be executed. …

  3. Proper api response error handling in python - Stack Overflow

    Apr 12, 2021 · Proper api response error handling in python Asked 4 years, 10 months ago Modified 4 years, 10 months ago Viewed 3k times

  4. python - Error handling when importing modules - Stack Overflow

    Jun 29, 2017 · This probably has an obvious answer, but I'm a beginner. I've got a "module" (really just a file with a bunch of functions I often use) at the beginning of which I import a number of other modules.

  5. How do I print an exception in Python? - Stack Overflow

    Python 3: logging Instead of using the basic print() function, the more flexible logging module can be used to log the exception. The logging module offers a lot extra functionality, for example, logging …

  6. python - how to catch specific pyodbc error message - Stack Overflow

    Jul 9, 2012 · In pyodbc 3.0.7, it works fine to catch pyodbc.ProgrammingError (and presumably the other error types, although I haven't tried). The contents of the error are still sort of cryptic, though, so it …

  7. python - Handle JSON Decode Error when nothing returned - Stack …

    There is a rule in Python programming called "it is Easier to Ask for Forgiveness than for Permission" (in short: EAFP). It means that you should catch exceptions instead of checking values for validity.

  8. python - What is best practice for flask error handling ... - Stack ...

    For returning a 400/500 response to clients in a flask webapp, I've seen the following conventions: Abort import flask def index(arg): return flask.abort("Invalid request", 400) Tuple def in...

  9. python - Catch exceptions inside a class - Stack Overflow

    Sep 18, 2018 · The catch_exception decorator would look for a msg attribute on its argument and use it, if found, in handling the exception. This approach could be extended; instead of a string, msg could …

  10. python - Why is "except: pass" a bad programming practice ... - Stack ...

    Feb 4, 2014 · python exception error-handling try-catch edited Jul 5, 2020 at 10:00 Cleb 26.3k 23 129 164