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

  2. Manually raising (throwing) an exception in Python

    Jun 13, 2022 · For the more advanced python users who have used python may think that the expression will be evaluated at compile time (python is compiled) but the python compiler wont …

  3. Catching an exception while using a Python 'with' statement

    I can't figure out how to handle exception for python 'with' statement. If I have a code: with open("a.txt") as f: print f.readlines()

  4. API Gateway + Lambda + Python: Handling Exceptions

    Nov 4, 2016 · To create exceptions with enough details in their message, error-handling-patterns-in-amazon-api-gateway-and-aws-lambda blog recommends that you create an exception …

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

    Or, for Python 2 only: except (IDontLikeYouException, YouAreBeingMeanException), e: pass Separating the exception from the variable with a comma will still work in Python 2.6 and 2.7, …

  6. How do I print an exception in Python? - Stack Overflow

    You’d only ever need to pass in an exception explicitly when not handling an exception or when you want to show info based on a different exception. – Martijn Pieters Commented Oct 7, …

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

    Aug 21, 2022 · ok_codes_int = isinstance(ok_status_codes, int) ok_codes_list = isinstance(ok_status_codes, list) if ok_status_codes != None and (not ok_codes_int) and (not …

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

  9. How do I test for exceptions in if-statements in python?

    Jan 25, 2013 · You have try-except to handle exceptions in Python: - def reporter(f,x): try: if f(x): # f(x) is not None and not throw any exception. Your last case return "Generic" # f(x) is `None` …

  10. Python Multiprocessing: Handling Child Errors in Parent

    Nov 12, 2013 · @Chris I haven't touched MP for a long time now so I can't remember. I think I had something that worked with passing exceptions based on the linked discussion to Ned …

Refresh