About 50 results
Open links in new tab
  1. python - When I catch an exception, how do I get the type, file, and ...

    56 Source (Py v2.7.3) for traceback.format_exception () and called/related functions helps greatly. Embarrassingly, I always forget to Read the Source. I only did so for this after searching for similar …

  2. Manually raising (throwing) an exception in Python

    How do I raise an exception in Python so that it can later be caught via an except block?

  3. 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 …

  4. Best Practices for Python Exceptions? - Stack Overflow

    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 …

  5. python - How do I properly assert that an exception gets raised in ...

    Important note: If the exception was raised without a message, execinfo.value.args will be an empty tuple, meaning trying to do execinfo.value.args[0] will raise an exception.

  6. python - How do I determine what type of exception occurred? - Stack ...

    If you care about the type of exception, it's because you've already considered what types of exception might logically occur.

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

    As of Python 3.11 you can take advantage of the except* clause that is used to handle multiple exceptions. PEP-654 introduced a new standard exception type called ExceptionGroup that …

  8. python - Difference between except: and except Exception as e: - Stack ...

    Apr 6, 2021 · The one you linked to asks what's the difference between except Exception, e: and except Exception as e:. This question asks what the difference is between except: and except Exception as e:.

  9. python - com_error: (-2147352567, 'Exception occurred.', (0, None, …

    Mar 10, 2019 · 3 I have found this related article: Python Interactions with Excel Macros The code there is for python 2. The most important part is that closing the workbook and quitting the app resulted in …

  10. Python "raise from" usage - Stack Overflow

    In other words, Python sets a context on exceptions so you can introspect where an exception was raised, letting you see if another exception was replaced by it.