##// END OF EJS Templates
Python 3 compatibility in IPython.lib.pretty
Thomas Kluyver -
Show More
@@ -454,8 +454,10 b' class GroupQueue(object):'
454 except ValueError:
454 except ValueError:
455 pass
455 pass
456
456
457
457 try:
458 _baseclass_reprs = (object.__repr__, types.InstanceType.__repr__)
458 _baseclass_reprs = (object.__repr__, types.InstanceType.__repr__)
459 except AttributeError: # Python 3
460 _baseclass_reprs = (object.__repr__,)
459
461
460
462
461 def _default_pprint(obj, p, cycle):
463 def _default_pprint(obj, p, cycle):
@@ -648,23 +650,33 b' _type_pprinters = {'
648 tuple: _seq_pprinter_factory('(', ')', tuple),
650 tuple: _seq_pprinter_factory('(', ')', tuple),
649 list: _seq_pprinter_factory('[', ']', list),
651 list: _seq_pprinter_factory('[', ']', list),
650 dict: _dict_pprinter_factory('{', '}', dict),
652 dict: _dict_pprinter_factory('{', '}', dict),
651 types.DictProxyType: _dict_pprinter_factory('<dictproxy {', '}>'),
653
652 set: _seq_pprinter_factory('set([', '])', set),
654 set: _seq_pprinter_factory('set([', '])', set),
653 frozenset: _seq_pprinter_factory('frozenset([', '])', frozenset),
655 frozenset: _seq_pprinter_factory('frozenset([', '])', frozenset),
654 super: _super_pprint,
656 super: _super_pprint,
655 _re_pattern_type: _re_pattern_pprint,
657 _re_pattern_type: _re_pattern_pprint,
656 type: _type_pprint,
658 type: _type_pprint,
657 types.ClassType: _type_pprint,
658 types.FunctionType: _function_pprint,
659 types.FunctionType: _function_pprint,
659 types.BuiltinFunctionType: _function_pprint,
660 types.BuiltinFunctionType: _function_pprint,
660 types.SliceType: _repr_pprint,
661 types.SliceType: _repr_pprint,
661 types.MethodType: _repr_pprint,
662 types.MethodType: _repr_pprint,
662 xrange: _repr_pprint,
663
663 datetime.datetime: _repr_pprint,
664 datetime.datetime: _repr_pprint,
664 datetime.timedelta: _repr_pprint,
665 datetime.timedelta: _repr_pprint,
665 _exception_base: _exception_pprint
666 _exception_base: _exception_pprint
666 }
667 }
667
668
669 try:
670 _type_pprinters[types.DictProxyType] = _dict_pprinter_factory('<dictproxy {', '}>')
671 _type_pprinters[types.ClassType] = _type_pprint,
672 except AttributeError: # Python 3
673 pass
674
675 try:
676 _type_pprinters[xrange] = _repr_pprint
677 except NameError:
678 _type_pprinters[range] = _repr_pprint
679
668 #: printers for types specified by name
680 #: printers for types specified by name
669 _deferred_type_pprinters = {
681 _deferred_type_pprinters = {
670 }
682 }
General Comments 0
You need to be logged in to leave comments. Login now