Terry J. Reedy <tjre...@udel.edu> added the comment:

Printing an exception is defined as printing the exception message, which 
currently is e.args[0].  We will not change that as it would break code 
worldwide.  To print more, the class name can be used directly or as a key into 
a dict of replacements or replacement functions.

Questions and vague ideas should be directed to python-list.  Fleshed out ideas 
can go to python-ideas.

>>> {}['d']
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    {}['d']
KeyError: 'd'

>>> try:
        {}['d']
except Exception as e:
        print(e)
        
'd'

>>> try:
        {}['d']
except Exception as e:
        print(e.args)

('d',)

>>> try:
        {}['d']
except Exception as e:
        print(f'{e.__class__.__name__}: {e}')  # Reproduce standard report.

KeyError: 'd'

----------
nosy: +terry.reedy
resolution:  -> rejected
stage:  -> resolved
status: open -> closed
versions: +Python 3.10

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42177>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to