About 216,000 results
Open links in new tab
  1. How do I print an exception in Python? - Stack Overflow

    144 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 …

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

  3. Correct way to try/except using Python requests module?

    try: r = requests.get (url, params= {'s': thing}) except requests.ConnectionError, e: print (e) Is this correct? Is there a better way to structure this? Will this cover all my bases?

  4. How do I declare custom exceptions in modern Python?

    By "modern Python" I mean something that will run in Python 2.5 but be 'correct' for the Python 2.6 and Python 3.* way of doing things. And by "custom" I mean an Exception object that can include extra …

  5. Catching an exception while using a Python 'with' statement

    The best way to handle exceptions in python is to write a function that catches and returns them? Seriously? The pythonic way to handle exceptions is to use a try...except statement.

  6. What is a good way to handle exceptions when trying to read a file in ...

    I want to read a .csv file in python. I don't know if the file exists. My current solution is below. It feels sloppy to me because the two separate exception tests are awkwardly juxtaposed. Is th...

  7. python - When I catch an exception, how do I get the type, file, and ...

    None of these solutions find the line of code where the exception happened, @Apogentus. Maybe it's because it's Python 2 code or something but these solutions find the line of code much nearer where …

  8. python - How to handle errors with boto3? - Stack Overflow

    I am trying to figure how to do proper error handling with boto3.

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

  10. Catch a thread's exception in the caller thread? - Stack Overflow

    Mar 28, 2022 · If you are using six or on Python 3 only, you can improve the stack trace information you get when the exception is re-raised. Instead of only the stack at the point of the join, you can wrap …