def strip_bracketed(s, c):
    """If s begins and ends with c, strip off c.
       c can be a single character like '"',
       or a pair of characters like '[]'.
       Also removes trailing commas.
    """
    start_char = c[0]
    if len(c) > 1:
        end_char = c[1]
    else:
        end_char = start_char
    s = s.strip()
    if s.endswith(','):
        s = s[:-1].strip()
    if s.startswith(start_char):
        s = s[1:].strip()
    if s.endswith(end_char):
        s = s[:-1].strip()
    return s
