def maybe_hex(item, list_depth=0):
    if isinstance(item, bool):
        return repr(item)
    if isinstance(item, (int, long)):
        return hex(item)
    elif isinstance(item, (list,)):
        return '[%s]' % joinlist(item, list_depth + 1)
    elif isinstance(item, (set,)):
        return '{%s}' % joinlist(item, list_depth + 1)
    elif isinstance(item, (dict,)):
        return '{%s}' % joindict(item, list_depth + 1)
    elif isinstance(item, (tuple,)):
        return '(%s)' % joinlist(item, list_depth + 1)
    else:
        return repr(item)

def get_joiner(lst, list_depth):
    joiner = ',\n' if len(repr(lst)) > 80 and len(lst) < 400 else ', '
    if joiner[1] == '\n':
        joiner += ' '*list_depth
    return joiner

def joinlist(lst, list_depth):
    return get_joiner(lst, list_depth).join(maybe_hex(a, list_depth) for a in lst)

def joindict(dct, list_depth):
    return get_joiner(dct, list_depth).join(
        '%s: %s' % (maybe_hex(key, list_depth), maybe_hex(val, list_depth))
                for key, val in dct.iteritems()
    )

def hex_print(item):
    if type(item) is bool:
        old_display_hook(item)
        return
    elif item is None:
        old_display_hook(item)
        return

    representation = maybe_hex(item)
    class hexprinted(type(item)):
        def __init__(self, qqq):
            self.__qqq = qqq
            super(hexprinted, self).__init__(qqq)

        def __repr__(self):
            return maybe_hex(item)
    try:
        old_display_hook(hexprinted(item))
    except:
        old_display_hook(item)

import sys
old_display_hook = sys.displayhook
sys.displayhook = hex_print

@@ -1250,24 +1250,37 @@
 e_hex(item)%0A
+    try:%0A    
     class he
@@ -1305,24 +1305,28 @@
 )):%0A        
+    
 def __init__
@@ -1338,16 +1338,20 @@
 , qqq):%0A
+    
         
@@ -1383,16 +1383,20 @@
         
+    
 super(he
@@ -1430,24 +1430,28 @@
 q)%0A%0A        
+    
 def __repr__
@@ -1466,24 +1466,28 @@
             
+   
+ 
 return maybe
@@ -1493,33 +1493,24 @@
 e_hex(item)%0A
-    try:%0A
         old_

Deal with old-style classes correctly