def dict2str(dictionary, **kwargs):
    """Converts a dict to a string expression.

    Args:
        dictionary (dict): A dictionary to convert to a string.

    Keyword Args:
        inverse_dict(boolean): Apply inverse order of string (default: ``False``).

    Returns:
        str: The dictionary as flattened text.

    Example:
        ``>>> dict2str({e: 1, f: 2, ...})``
        ``Out[]: "{e: 1, f: 2, ...}"``
    """

    if kwargs.get("inverse_dict"):
        inverse_dict = kwargs.get("inverse_dict")
    else:
        inverse_dict = False  # optional keyword arg: if true: dictionary keys and values will be inversed

    dict_str = "{"
    cc = 1
    for k, v in dictionary.items():
        skey = "\'%s\'" % k if type(k) == str else str(k)
        sval = "\'%s\'" % v if type(v) == str else str(v)
        if not inverse_dict:
            dict_str += "{0}: {1}".format(skey, sval)
        else:
            dict_str += "{1}: {0}".format(skey, sval)
        if not (cc == dictionary.__len__()):
            dict_str += ", "
        else:
            dict_str += "}"
        cc += 1
    return dict_str