<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def prepare_path(path, replace_space, replace_sep, expandvars, expanduser):
 """ Performs `os.path` replacement operations on a path string. :param path: Path string :type path: unicode | str :param replace_space: Mask spaces with backslash. :param replace_sep: Replace potentially different path separators with POSIX path notation (use :const:`posixpath.sep`). :type replace_sep: bool :param expandvars: Expand environment variables (:func:`~os.path.expandvars`). :type expandvars: bool :param expanduser: Expand user variables (:func:`~os.path.expanduser`). :type expanduser: bool :return: Path string from `path` with aforementioned replacements. :rtype: unicode | str """

    r_path = path
    if expandvars:
        r_path = os.path.expandvars(r_path)
    if expanduser:
        r_path = os.path.expanduser(r_path)
    if replace_sep and os.sep != posixpath.sep:
        r_path = r_path.replace(os.path.sep, posixpath.sep)
    if replace_space:
        r_path = r_path.replace(' ', '\\ ')
    return r_path