On 23 September 2014 22:52, Tarek Ziadé <tarek@ziade.org> wrote:
Le 23/09/14 14:51, Todd a écrit :
What about something like os.path.homedir or os.homedir? You could use, for example, homedir() to get the home directory of the current user, and homedir('username') to get the home directory of a given user (if that is possible).
Sounds way better!
Given the naming of site.getuserbase(), site.getusersite(), and os.expanduser(), a simple "os.userdir()" (to parallel "os.curdir()") may be appropriate. Then making a path that is relative to the user dir absolute would be: abspath = os.path.join(os.userdir(), relpath) While the inverse operation would be: relpath = os.path.relpath(abspath, start=os.userdir()) os.path.expanduser() would then be primarily about dealing with *longer* paths that have "~" embedded, rather than the degenerate case of "os.expanduser('~')". Regards, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia