A better str(_get_keycodes()) method

def get_string():
    """A better str(_get_keycodes()) method"""
    keycodes = _get_keycodes()
    initial_code, codes = keycodes[0], keycodes[1:]
    initial_char = chr(initial_code)
    if initial_code == 27:
        initial_char = '\\e'
    elif not ascii.isgraph(initial_char):
        initial_char = '\\x%x' % initial_code
    chars = ''.join([chr(c) for c in codes])
    return ''.join((initial_char, chars))