human
Complete this python program:
def coerce_range_list_param(p, frames=None, numeric=True):
assistant
#Here is the Python program you requested.

    """Coerces and/or verifies the object *p* into a valid range-list-format parameter.
    As defined in `Section 8.7.2 of Simple
    Spectral Access Protocol
    <http://www.ivoa.net/Documents/REC/DAL/SSA-20080201.html>`_.
    Parameters
    p : str or sequence
    May be a string as passed verbatim to the service expecting a
    range-list, or a sequence.  If a sequence, each item must be
    either:
    - a numeric value
    - a named value, such as, for example, \J\ for named
    spectrum (if the *numeric* kwarg is False)
    - a 2-tuple indicating a range
    - the last item my be a string indicating the frame of
    reference
    frames : sequence of str, optional
    A sequence of acceptable frame of reference keywords.  If not
    provided, the default set in ``set_reference_frames`` will be
    used.
    numeric : bool, optional
    TODO
    Returns
    parts : tuple
    The result is a tuple:
    - a string suitable for passing to a service as a range-list
    argument
    - an integer counting the number of elements
    """
    def str_or_none(x):
        if (x is None):
            return u''
        if numeric:
            x = float(x)
        return str(x)
    def numeric_or_range(x):
        if (isinstance(x, tuple) and (len(x) == 2)):
            return u'{}/{}'.format(str_or_none(x[0]), str_or_none(x[1]))
        else:
            return str_or_none(x)
    def is_frame_of_reference(x):
        return isinstance(x, six.string_types)
    if (p is None):
        return (None, 0)
    elif isinstance(p, (tuple, list)):
        has_frame_of_reference = ((len(p) > 1) and is_frame_of_reference(p[(-1)]))
        if has_frame_of_reference:
            points = p[:(-1)]
        else:
            points = p[:]
        out = u','.join([numeric_or_range(x) for x in points])
        length = len(points)
        if has_frame_of_reference:
            if ((frames is not None) and (p[(-1)] not in frames)):
                raise ValueError(u"'{}'    is    not    a    valid    frame    of    reference".format(p[(-1)]))
            out += (u';' + p[(-1)])
            length += 1
        return (out, length)
    elif isinstance(p, six.string_types):
        number = u'([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)?'
        if (not numeric):
            number = ((u'(' + number) + u')|([A-Z_]+)')
        match = re.match(((((u'^' + number) + u'([,/]') + number) + u')+(;(?P<frame>[<A-Za-z_0-9]+))?$'), p)
        if (match is None):
            raise ValueError(u"'{}'    is    not    a    valid    range    list".format(p))
        frame = match.groupdict()[u'frame']
        if ((frames is not None) and (frame is not None) and (frame not in frames)):
            raise ValueError(u"'{}'    is    not    a    valid    frame    of    reference".format(frame))
        return (p, ((p.count(u',') + p.count(u';')) + 1))
    try:
        float(p)
        return (str(p), 1)
    except TypeError:
        raise ValueError(u"'{}'    is    not    a    valid    range    list".format(p))