human
I wrote the below code

    def replace_insane(char):
        if (restricted and (char in ACCENT_CHARS)):
            return ACCENT_CHARS[char]
        if ((char == u'?') or (ord(char) < 32) or (ord(char) == 127)):
            return u''
        elif (char == u'"'):
            return (u'' if restricted else u"'")
        elif (char == u':'):
            return (u'_-' if restricted else u'    -')
        elif (char in u'\\/|*<>'):
            return u'_'
        if (restricted and ((char in u"!&'()[]{}$;`^,#") or char.isspace())):
            return u'_'
        if (restricted and (ord(char) > 127)):
            return u'_'
        return char
    s = re.sub(u'[0-9]+(?::[0-9]+)+', (lambda m: m.group(0).replace(u':', u'_')), s)
    result = u''.join(map(replace_insane, s))
    if (not is_id):
        while (u'__' in result):
            result = result.replace(u'__', u'_')
        result = result.strip(u'_')
        if (restricted and result.startswith(u'-_')):
            result = result[2:]
        if result.startswith(u'-'):
            result = (u'_' + result[len(u'-'):])
        result = result.lstrip(u'.')
        if (not result):
            result = u'_'
    return result

What's a good function header?

=====
Here's a good function header?
assistant
#Here's a good function header.

def sanitize_filename(s, restricted=False, is_id=False):