(
    text: str,
    *,
    only: Optional[str | Collection[str]] = None,
)
Remove punctuation from ``text`` by replacing all instances of punctuation
    (or a subset thereof specified by ``only``) with whitespace.

    Args:
        text
        only: Remove only those punctuation marks specified here. For example,
            ``"."`` removes only periods, while ``[",", ";", ":"]`` removes commas,
            semicolons, and colons; if None, all unicode punctuation marks are removed.

    Returns:
        str

    Note:
        When ``only=None``, Python's built-in :meth:`str.translate()` is
        used to remove punctuation; otherwise, a regular expression is used.
        The former's performance can be up to an order of magnitude faster.
Remove punctuation from ``text`` by replacing all instances of punctuation
    (or a subset thereof specified by ``only``) with whitespace.
Remove punctuation from text by replacing all instances of punctuation ( or a subset thereof specified by only ) with whitespace .
def punctuation(
    text: str,
    *,
    only: Optional[str | Collection[str]] = None,
) -> str:
    """
    Remove punctuation from ``text`` by replacing all instances of punctuation
    (or a subset thereof specified by ``only``) with whitespace.

    Args:
        text
        only: Remove only those punctuation marks specified here. For example,
            ``"."`` removes only periods, while ``[",", ";", ":"]`` removes commas,
            semicolons, and colons; if None, all unicode punctuation marks are removed.

    Returns:
        str

    Note:
        When ``only=None``, Python's built-in :meth:`str.translate()` is
        used to remove punctuation; otherwise, a regular expression is used.
        The former's performance can be up to an order of magnitude faster.
    """
    if only is not None:
        only = utils.to_collection(only, val_type=str, col_type=set)
        return re.sub("[{}]+".format(re.escape("".join(only))), " ", text)
    else:
        return text.translate(resources.PUNCT_TRANSLATION_TABLE)
def punctuation ( text : str , * , only : Optional [ str | Collection [ str ] ] = None , ) -> str : if only is not None : only = utils . to_collection ( only , val_type = str , col_type = set ) return re . sub ( "[{}]+" . format ( re . escape ( "" . join ( only ) ) ) , " " , text ) else : return text . translate ( resources . PUNCT_TRANSLATION_TABLE )