About 17,400,000 results
Open links in new tab
  1. python - How to properly ignore exceptions - Stack Overflow

    When you just want to do a try-except without handling the exception, how do you do it in Python? Is the following the right way to do it? try: shutil.rmtree(path) except: pass

  2. python - I'm getting an IndentationError (or a TabError). How do I …

    See Else clause on Python while statement See How to fix Python indentation for more tools and techniques to clean up indentation to conform to standards (even if it already "works"). Keep in …

  3. python - One try block with multiple excepts - Stack Overflow

    In Python, is it possible to have multiple except statements for one try statement? Such as: try: #something1 #something2 except ExceptionType1: #return xyz except ExceptionType2: #...

  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 …

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

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

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

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

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

  9. python - Get HTTP Error code from requests.exceptions.HTTPError

    Thanks a ton. Seems like this is the only way to handle errors in any HTTP methods using python requests.

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