human
I wrote the below code

    def ascii(b):
        'Determine    how    to    show    a    byte    in    ascii.'
        if (32 <= b <= 126):
            return chr(b)
        else:
            return '.'
    pos = 0
    ascii_map = [ascii(c) for c in range(256)]
    lastbuf = ''
    lastline = ''
    repeat_count = 0
    if (width > 4):
        space_col = (width / 2)
    else:
        space_col = (-1)
    if (type(source) == str):
        source = StringIO(source)
    if start:
        source.seek(start)
        pos = start
    hex_field_width = ((width * 3) + 1)
    total_read = 0
    while True:
        if limit:
            to_read = min((limit - total_read), width)
        else:
            to_read = width
        buf = source.read(to_read)
        length = len(buf)
        total_read += length
        if (length == 0):
            if (repeat_count and (not show_repeats)):
                if (repeat_count > 1):
                    print >>out, (REPEAT_FORMAT % (repeat_count - 1))
                elif (repeat_count == 1):
                    print >>out, lastline
                print >>out, lastline
            break
        else:
            show_buf = True
            if (buf == lastbuf):
                repeat_count += 1
                show_buf = False
            elif (repeat_count and (not show_repeats)):
                if (repeat_count == 1):
                    print >>out, lastline
                else:
                    print >>out, (REPEAT_FORMAT % (repeat_count - 1))
                repeat_count = 0
            hex = ''
            asc = ''
            for i in range(length):
                c = buf[i]
                if (i == space_col):
                    hex = (hex + '    ')
                hex = ((hex + ('%02x' % ord(c))) + '    ')
                asc = (asc + ascii_map[ord(c)])
            line = ('%06x:    %-*s    %s' % (pos, hex_field_width, hex, asc))
            if show_buf:
                print >>out, line
            pos = (pos + length)
            lastbuf = buf
            lastline = line

What's a good function header?

=====
What is a Python code to determine    how    to    show    a    byte    in    ascii?
assistant
#Here is Python code to determine    how    to    show    a    byte    in    ascii.

def hexdump(source, out, width=16, start=0, limit=None, show_repeats=False):