def str_set_of_candidates(candset, cand_names=None):
    """
    Nicely format a set of candidates.

    .. doctest::

        >>> print(str_set_of_candidates({0, 1, 3, 2}))
        {0, 1, 2, 3}
        >>> print(str_set_of_candidates({0, 3, 1}, cand_names="abcde"))
        {a, b, d}

    Parameters
    ----------
        candset : iterable of int
            An iteratble of candidates.

        cand_names : list of str or str, optional
            List of symbolic names for every candidate.

    Returns
    -------
        str
    """
    if cand_names is None:
        named = sorted(str(cand) for cand in candset)
    else:
        named = sorted(str(cand_names[cand]) for cand in candset)
    return "{" + ", ".join(named) + "}"