Mark Dickinson added the comment:
+1. I recently chastised a colleague for doing "raise KeyError(long_message)"
instead of "raise KeyError(missing_item)". When I went to the standard library
to support my POV, I found (to my chagrin) a big mix of the two styles.
>>> from collections import ChainMap
>>> d = ChainMap({}, {})
>>> try:
... d.pop('not there')
... except KeyError as e:
... key, = e.args
...
>>> key
"Key not found in the first mapping: 'not there'"
----------
nosy: +mark.dickinson
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue18163>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com