About 505,000 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. python - How to handle FileNotFoundError when "try .. except IOError ...

    Possible duplicate of Python's "open ()" throws different errors for "file not found" - how to handle both exceptions?

  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. Manually raising (throwing) an exception in Python

    How do I manually throw/raise an exception in Python? Use the most specific Exception constructor that semantically fits your issue. Be specific in your message, e.g.:

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

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

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

    Mar 28, 2022 · t.join() And you'll see the exception raised on the other thread when you join. If you are using six or on Python 3 only, you can improve the stack trace information you get when the …

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

  10. I want to exception handle 'list index out of range.'

    The problem is, some of the HTMLs have different format (and they don't have the data that I want in them). So, I was trying to use exception handling and add value null to the list (I should do this since …