import re


def strip_2ws(astr, strip=True):
    """
    Strips double white spaces

    :param astr: (str) - a string
    :param strip: (boolean) - whether to strip whitespace on edges
    """
    if strip:
        return re.sub(' +', ' ', astr).strip()
    else:
        return re.sub(' +', ' ', astr)