human
I wrote the below code

    def decode(m):
        html = m.group(0)
        if (html[:2] == u'&#'):
            try:
                if (html[:3] == u'&#x'):
                    return chr(int(html[3:(-1)], 16))
                else:
                    return chr(int(html[2:(-1)]))
            except ValueError:
                pass
        else:
            try:
                html = chr(name2codepoint[html[1:(-1)]])
            except KeyError:
                pass
        return html
    return re.sub(u'&#?\\w+;', decode, html.replace(u'&amp;', u'&'))

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

def decode_entities(html):