What is the reason that raising a KeyError
does not format the string whereas other errors do? (notice the embedded \n
vs a new line in the examples below)
In [1]: raise KeyError("Does not \n format")
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-1-2a34667e842b> in <module>()
----> 1 raise KeyError("Does not \n format")
KeyError: 'Does not \n format'
Whereas for a ValueError
In [2]: raise ValueError("Does \n format")
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-2-3f8ba28869e2> in <module>()
----> 1 raise ValueError("Does \n format")
ValueError: Does
format
Or an IndexError
In [3]: raise IndexError("Does \n format")
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-4-2db4e87594fd> in <module>()
----> 1 raise IndexError("Does \n format")
IndexError: Does
format