homepage

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 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:38Shawn.Brownsetrecipients: + Shawn.Brown
2012年06月04日 04:59:38Shawn.Brownsetmessageid: <1338785978.19.0.656229805184.issue14998@psf.upfronthosting.co.za>
2012年06月04日 04:59:37Shawn.Brownlinkissue14998 messages
2012年06月04日 04:59:37Shawn.Browncreate

AltStyle によって変換されたページ (->オリジナル) /