About 148,000 results
Open links in new tab
  1. 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 …

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

  3. What is a good way to handle exceptions when trying to read a …

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

  4. python - When I catch an exception, how do I get the type, file, …

    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 …

  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. python - I want to exception handle 'list index out of range.'

    I want to exception handle 'list index out of range.' Asked 13 years, 4 months ago Modified 3 years, 6 months ago Viewed 451k times

  7. python - Catch a thread's exception in the caller thread ... - Stack ...

    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 …

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

    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 …

  9. python - How to handle FileNotFoundError when "try .. except …

    Make sure you are placing your exception handler in the correct location. Take a close look at the traceback for the exception to make sure you didn't miss where it is actually being raised.

  10. python exception handling - Stack Overflow

    Jan 4, 2011 · import logging logging.basicConfig(level=logging.DEBUG) logging.debug('This message should go to the log file') try: 1/0 except Exception as e: logging.exception(e) This …