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 doerwalter
Recipients
Date 2005年11月10日.22:56:22
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Logged In: YES 
user_id=89016
In theory this should be possible by subclassing
pprint.PrettyPrinter and overwritting the format method:
import pprint
class MyPrettyPrinter(pprint.PrettyPrinter):
 def format(self, object, context, maxlevels, level):
 if isinstance(object, int):
 return hex(object), True, False
 else:
 return pprint.PrettyPrinter.format(self, object,
context, maxlevels, level)
mpp = MyPrettyPrinter()
mpp.pprint(range(50))
This doesn't work reliable though: When the string is short
enough, format() seems to be bypassed and repr() is called
directly.
History
Date User Action Args
2007年08月23日 16:11:29adminlinkissue1351692 messages
2007年08月23日 16:11:29admincreate

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