About 9,970,000 results
Open links in new tab
  1. 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?

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

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

  4. python - errors=surrogateescape vs errors=replace - Stack Overflow

    Jun 4, 2019 · So with replace, you get valid unicode characters, but lose the original content of the file, while with surrogateescape, you can know the original bytes (and can even rebuild it …

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

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

    Aug 21, 2022 · Correct way to try/except using Python requests module? Asked 12 years, 6 months ago Modified 10 months ago Viewed 1.1m times

  7. How do you test that a Python function throws an exception?

    Sep 25, 2008 · On Python < 2.7 this construct is useful for checking for specific values in the expected exception. The unittest function assertRaises only checks if an exception was raised.

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

  9. How to log python exception? - Stack Overflow

    How can I log an exception in Python? I've looked at some options and found out I can access the actual exception details using this code: import sys import traceback try: 1/0 except: ex...

  10. Python: Suppressing errors from going to commandline?

    Python: Suppressing errors from going to commandline? Asked 14 years, 6 months ago Modified 1 year, 4 months ago Viewed 50k times