Python · Exception Handling

In Python 3, what's the difference between raise ValueError (the bare class) and raise ValueError("bad value")?

Answer locked. Get the free KnowCard app to reveal it — plus spaced-repetition review so it actually sticks.

Get it on App StoreGet it on Google Play

This is one card from the KnowCard library — thousands more across SAP, Linux, Python and more. In the app you get the answer, AI explanations, and cards that come back right before you would forget them. Free to start on iOS, Android or the web.

More in Exception Handling

What does this print? (nested try) ``` try: try: raise TypeError except IndexError: print("inner") except TypeError: print("outer") ```
What happens if an exception is raised inside an except (or else / finally) branch — can a later except of the same try catch it?
In a try/except/else block, when does the else branch run?
What does this print? ``` def f(): try: return 1 finally: print("cleanup") print(f()) ```
What does this function return? ``` def f(): try: return "try" finally: return "finally" ```
Why is ordering except branches general-before-specific a bug? ``` try: risky() except Exception: a() except ValueError: b() ```

Start learning today

Free to start — download the app or use it in your browser.

Get it on App StoreGet it on Google Play