human
Here's a good function header given the following:
I wrote the below code

    if (type(pattern) is DateTimePattern):
        return pattern
    result = []
    quotebuf = None
    charbuf = []
    fieldchar = ['']
    fieldnum = [0]
    def append_chars():
        result.append(''.join(charbuf).replace('%', '%%'))
        del charbuf[:]
    def append_field():
        limit = PATTERN_CHARS[fieldchar[0]]
        if (limit and (fieldnum[0] not in limit)):
            raise ValueError(('Invalid    length    for    field:    %r' % (fieldchar[0] * fieldnum[0])))
        result.append(('%%(%s)s' % (fieldchar[0] * fieldnum[0])))
        fieldchar[0] = ''
        fieldnum[0] = 0
    for (idx, char) in enumerate(pattern.replace("''", '\x00')):
        if (quotebuf is None):
            if (char == "'"):
                if fieldchar[0]:
                    append_field()
                elif charbuf:
                    append_chars()
                quotebuf = []
            elif (char in PATTERN_CHARS):
                if charbuf:
                    append_chars()
                if (char == fieldchar[0]):
                    fieldnum[0] += 1
                else:
                    if fieldchar[0]:
                        append_field()
                    fieldchar[0] = char
                    fieldnum[0] = 1
            else:
                if fieldchar[0]:
                    append_field()
                charbuf.append(char)
        elif (quotebuf is not None):
            if (char == "'"):
                charbuf.extend(quotebuf)
                quotebuf = None
            else:
                quotebuf.append(char)
    if fieldchar[0]:
        append_field()
    elif charbuf:
        append_chars()
    return DateTimePattern(pattern, u''.join(result).replace('\x00', "'"))

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

def parse_pattern(pattern):