'Return a new path with expanded ~ and ~user constructs
(as returned by os.path.expanduser)'

def expanduser(self):

    if ((not (self._drv or self._root)) and self._parts and (self._parts[0][:1] == '~')):
        homedir = self._flavour.gethomedir(self._parts[0][1:])
        return self._from_parts(([homedir] + self._parts[1:]))
    return self
