def expandpath ( path ) : return os . path . expandvars ( os . path . expanduser ( path ) ) . replace ( "//" , "/" )
python expand a path
Expand a filesystem path that may or may not contain user / env vars .
def expandpath(path):
    """
    Expand a filesystem path that may or may not contain user/env vars.

    :param str path: path to expand
    :return str: expanded version of input path
    """
    return os.path.expandvars(os.path.expanduser(path)).replace("//", "/")