(dump)
return ''.join(res)
Very helpful when debugging.
Very helpful when debugging.
Very helpful when debugging .
def hexDump(dump):
        """Very helpful when debugging."""
        length = len(dump)
        P = lambda z: ((ord(z) >= 0x21 and ord(z) <= 0x7e) and [z] or ['.'])[0]
        ROWLEN = 18
        res = ['\n']
        for j in xrange(length // ROWLEN + int(length % ROWLEN > 0)):
            row = dump[j * ROWLEN:(j + 1) * ROWLEN]
            if isinstance(row, list):
                row = ''.join(row)
            res.append(
            ('%02X ' * len(row) + '   ' * (ROWLEN - len(row)) + '| %s\n') % \
                tuple(map(ord, list(row)) + [''.join(map(P, row))]))
        return ''.join(res)
def hexDump ( dump ) : length = len ( dump ) P = lambda z : ( ( ord ( z ) >= 0x21 and ord ( z ) <= 0x7e ) and [ z ] or [ '.' ] ) [ 0 ] ROWLEN = 18 res = [ '\n' ] for j in xrange ( length // ROWLEN + int ( length % ROWLEN > 0 ) ) : row = dump [ j * ROWLEN : ( j + 1 ) * ROWLEN ] if isinstance ( row , list ) : row = '' . join ( row ) res . append ( ( '%02X ' * len ( row ) + '   ' * ( ROWLEN - len ( row ) ) + '| %s\n' ) % tuple ( map ( ord , list ( row ) ) + [ '' . join ( map ( P , row ) ) ] ) ) return '' . join ( res )