This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients terry.reedy, zingero
Date 2020-10-30.23:35:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1604100937.95.0.201297081075.issue42177@roundup.psfhosted.org>
In-reply-to
Content
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'
History
Date User Action Args
2020-10-30 23:35:37terry.reedysetrecipients: + terry.reedy, zingero
2020-10-30 23:35:37terry.reedysetmessageid: <1604100937.95.0.201297081075.issue42177@roundup.psfhosted.org>
2020-10-30 23:35:37terry.reedylinkissue42177 messages
2020-10-30 23:35:37terry.reedycreate