Message162250
| Author |
Shawn.Brown |
| Recipients |
Shawn.Brown |
| Date |
2012年06月04日.04:59:37 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1338785978.19.0.656229805184.issue14998@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Currently, I'm monkey patching _safe_key (adding a try/except) as follows:
>>> import pprint
>>>
>>> class _safe_key(pprint._safe_key):
>>> def __lt__(self, other):
>>> try:
>>> rv = self.obj.__lt__(other.obj)
>>> except TypeError: # Exception instead of TypeError?
>>> rv = NotImplemented
>>>
>>> if rv is NotImplemented:
>>> rv = (str(type(self.obj)), id(self.obj)) < \
>>> (str(type(other.obj)), id(other.obj))
>>> return rv
>>>
>>> pprint._safe_key = _safe_key
>>>
>>> pprint.pprint({(0,): 1, (None,): 2})
{(None,): 2, (0,): 1} |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年06月04日 04:59:38 | Shawn.Brown | set | recipients:
+ Shawn.Brown |
| 2012年06月04日 04:59:38 | Shawn.Brown | set | messageid: <1338785978.19.0.656229805184.issue14998@psf.upfronthosting.co.za> |
| 2012年06月04日 04:59:37 | Shawn.Brown | link | issue14998 messages |
| 2012年06月04日 04:59:37 | Shawn.Brown | create |
|