Constructor for a wildcard-:class:`Pattern`

    Helper function to create a Pattern object with an emphasis on wildcard
    patterns, if we don't care about the arguments of the matched expressions
    (otherwise, use :func:`pattern`)

    Args:
        name_mode (str): Combined `wc_name` and `mode` for :class:`Pattern`
            constructor argument. See below for syntax
        head (type, or None): See :class:`Pattern`
        args (list or None): See :class:`Pattern`
        kwargs (dict or None): See :class:`Pattern`
        conditions (list or None): See :class:`Pattern`

    The `name_mode` argument uses trailing underscored to indicate the `mode`:

        * ``A`` -> ``Pattern(wc_name="A", mode=Pattern.single, ...)``
        * ``A_`` -> ``Pattern(wc_name="A", mode=Pattern.single, ...)``
        * ``B__`` -> ``Pattern(wc_name="B", mode=Pattern.one_or_more, ...)``
        * ``B___`` -> ``Pattern(wc_name="C", mode=Pattern.zero_or_more, ...)``

def wc(name_mode="_", head=None, args=None, kwargs=None, *, conditions=None) \
        -> Pattern:
    """Constructor for a wildcard-:class:`Pattern`

    Helper function to create a Pattern object with an emphasis on wildcard
    patterns, if we don't care about the arguments of the matched expressions
    (otherwise, use :func:`pattern`)

    Args:
        name_mode (str): Combined `wc_name` and `mode` for :class:`Pattern`
            constructor argument. See below for syntax
        head (type, or None): See :class:`Pattern`
        args (list or None): See :class:`Pattern`
        kwargs (dict or None): See :class:`Pattern`
        conditions (list or None): See :class:`Pattern`

    The `name_mode` argument uses trailing underscored to indicate the `mode`:

        * ``A`` -> ``Pattern(wc_name="A", mode=Pattern.single, ...)``
        * ``A_`` -> ``Pattern(wc_name="A", mode=Pattern.single, ...)``
        * ``B__`` -> ``Pattern(wc_name="B", mode=Pattern.one_or_more, ...)``
        * ``B___`` -> ``Pattern(wc_name="C", mode=Pattern.zero_or_more, ...)``
    """
    rx = re.compile(r"^([A-Za-z]?[A-Za-z0-9]*)(_{0,3})$")
    m = rx.match(name_mode)
    if not m:
        raise ValueError("Invalid name_mode: %s" % name_mode)
    wc_name, mode_underscores = m.groups()
    if wc_name == '':
        wc_name = None
    mode = len(mode_underscores) or Pattern.single
    return Pattern(head, args, kwargs, mode=mode, wc_name=wc_name,
                   conditions=conditions)