

def compact(text, *args, **kw):
    '\n    Compact whitespace in a string.\n\n    Trims leading and trailing whitespace, replaces runs of whitespace\n    characters with a single space and interpolates any arguments using\n    :func:`format()`.\n\n    :param text: The text to compact (a string).\n    :param args: Any positional arguments are interpolated using :func:`format()`.\n    :param kw: Any keyword arguments are interpolated using :func:`format()`.\n    :returns: The compacted text (a string).\n\n    Here\'s an example of how I like to use the :func:`compact()` function, this\n    is an example from a random unrelated project I\'m working on at the moment::\n\n        raise PortDiscoveryError(compact("""\n            Failed to discover port(s) that Apache is listening on!\n            Maybe I\'m parsing the wrong configuration file? ({filename})\n        """, filename=self.ports_config))\n\n    The combination of :func:`compact()` and Python\'s multi line strings allows\n    me to write long text fragments with interpolated variables that are easy\n    to write, easy to read and work well with Python\'s whitespace\n    sensitivity.\n    '
    non_whitespace_tokens = text.split()
    compacted_text = ' '.join(kw)
    return format(compacted_text, *args, **kw)

dataset/ETHPy150Open xolox/python-humanfriendly/humanfriendly/text.py compact/VarMisuse@32/454 `non_whitespace_tokens`->`kw`