About 50 results
Open links in new tab
  1. How do I declare custom exceptions in modern Python?

    How do I declare custom exception classes in modern Python? My primary goal is to follow whatever standard other exception classes have, so that (for instance) any extra string I …

  2. python - How can I write a `try`/`except` block that catches all ...

    In Python, all exceptions must be instances of a class that derives from BaseException, but if you can omit it for a general case - omit it, problem is, linters wine about it.

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

  4. Python: How to ignore an exception and proceed? [duplicate]

    Feb 22, 2009 · In Python 3, the variable that holds the exception instance gets deleted on exiting the except block. Even if the variable held a value previously, after entering and exiting the …

  5. Correct way of handling exceptions in Python? - Stack Overflow

    Aug 17, 2009 · Correct way of handling exceptions in Python? Asked 16 years, 6 months ago Modified 16 years, 3 months ago Viewed 25k times

  6. Why are Python exceptions named "Error"? - Stack Overflow

    94 Why are Python exceptions named "Error" (e.g. ZeroDivisionError, NameError, TypeError) and not "Exception" (e.g. ZeroDivisionException, NameException, TypeException). I come from a …

  7. Manually raising (throwing) an exception in Python

    Jan 12, 2010 · 113 In Python 3 there are four different syntaxes for raising exceptions: raise exception raise exception (args) raise raise exception (args) from original_exception 1. Raise …

  8. Is it a good practice to use try-except-else in Python?

    Apr 22, 2013 · Even the Python core developers use exceptions for flow-control and that style is heavily baked into the language (i.e. the iterator protocol uses StopIteration to signal loop …

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

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

    Feb 4, 2014 · Using exceptions this way caused a lot of controversy, especially when iterators and generators were first introduced to Python, but eventually the idea prevailed.