[Python-ideas] proposal: os.path.joinuser()

Tarek Ziadé tarek at ziade.org
Tue Sep 23 09:19:29 CEST 2014


Hello

I realize I am using a lot this pattern:

   >>> os.path.join(os.path.expanduser('~'), 'something', 'here')
   '/Users/tarek/something/here'
 

It's quite complicated, and not really intuitive.

What about adding in os.path a "joinuser()" equivalent function, e.g.

  >>> os.path.joinuser('something', here')   
  '/Users/tarek/something/here'


With an optional "user" argument when you want to specify the ~user

  >>> os.path.joinuser('something', here', user="foo")
   '/Users/bill/something/here'

That would be, in my opinion, much more explicit & readable.

If there's already something like that in the stdlib, forgive my ignorance!

Cheers
Tarek






More information about the Python-ideas mailing list