human
I wrote the below code

    from itertools import groupby
    if (r.http != 'GET'):
        r.error(405, current.ERROR.BAD_METHOD)
    T = current.T
    db = current.db
    s3db = current.s3db
    response = current.response
    s3 = response.s3
    has_permission = current.auth.s3_has_permission
    person = r.record
    ctable = s3db.pr_contact
    query = (ctable.pe_id == person.pe_id)
    resource = s3db.resource('pr_contact')
    resource.add_filter(query)
    access = s3.pr_contacts
    if access:
        resource.add_filter((FS('contact.access') == access))
    fields = ['id', 'contact_description', 'value', 'contact_method']
    contacts = resource.select(fields)['rows']
    contact_groups = {}
    for (key, group) in groupby(contacts, (lambda c: c['pr_contact.contact_method'])):
        contact_groups[key] = list(group)
    contacts_wrapper = DIV(H2(T('Contacts')))
    person_update_permission = has_permission('update', 'pr_person', record_id=person.id)
    if (person_update_permission and has_permission('create', ctable)):
        add_btn = DIV(A(T('Add'), _class='action-btn', _id='contact-add'), DIV(_id='contact-add_throbber', _class='throbber    hide'), _class='margin')
        contacts_wrapper.append(add_btn)
    items = contact_groups.items()
    def mysort(key):
        '    Sort    Contact    Types    by    Priority'
        keys = {'SMS': 1, 'EMAIL': 2, 'WORK_PHONE': 3, 'HOME_PHONE': 4, 'SKYPE': 5, 'RADIO': 6, 'TWITTER': 7, 'FACEBOOK': 8, 'FAX': 9, 'OTHER': 10, 'IRC': 11, 'GITHUB': 12, 'LINKEDIN': 13, 'BLOG': 14}
        return keys[key[0]]
    items.sort(key=mysort)
    opts = current.msg.CONTACT_OPTS
    def action_buttons(table, contact_id):
        if has_permission('update', ctable, record_id=contact_id):
            edit_btn = A(T('Edit'), _class='editBtn    action-btn    fright')
        else:
            edit_btn = DIV()
        if has_permission('delete', ctable, record_id=contact_id):
            delete_btn = A(T('Delete'), _class='delete-btn-ajax    fright')
        else:
            delete_btn = DIV()
  ...

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

def pr_contacts(r, **attr):