[Python-Dev] Should KeyError use repr() on its argument?

Guido van Rossum guido@python.org
Tue, 03 Sep 2002 15:41:10 -0400


(SF bug 598451.)

The KeyError exception doesn't apply repr() to its argument.  That's
annoying in cases like this:

  >>> a = {}
  >>> a['']
  Traceback (most recent call last):
    File "<stdin>", line 1, in ?
  KeyError
  >>> 

Should this be fixed?  How?  (I guess we could add a KeyError__str__
method to exceptions.c that applies repr().)

I've got a feeling this is a feature, but not a very useful one.

--Guido van Rossum (home page: http://www.python.org/~guido/)