is pathlib Path.resolve working as intended?

Chris Cioffi chris at evenprimes.com
Wed Dec 24 09:09:30 EST 2014


That's what I thought as well.  Then I found https://bugs.python.org/issue19776 and it looks like this is a well known issue.  Hopefully the patches are working and will be accepted in the next release or so.  

Given how often os.path.expanduser() is needed, I'm a little surprised that the pathlib module was even put in provisionally.  I do like how it works, however.  Paths as objects and not strings!  Its a beautiful idea, just not 100% complete.

PS:  For those who are curious, the 2 issues that seemed to hold things up the most are non-Unix systems (Windows) and how to handle when there is no home directory.  Posix only says that the results are undefined.  

> On Dec 24, 2014, at 8:38 AM, Skip Montanaro <skip.montanaro at gmail.com> wrote:
> 
>>>> p.resolve()
> ...
> FileNotFoundError: [Errno 2] No such file or directory: '/Users/chris/~'
> 
> I've not used the pathlib module yet, but poked through the
> documentation. Oddly enough, I saw no mention of "~". The doc for the
> resolve method only mentions resolving symlinks. In addition, the
> pathlib doc doesn't mention "expand" either.
> 
> My guess is your working directory was /Users/chris, and that "~"
> expansion isn't supported by pathlib. Even so, it seems like a common
> enough task that I'd open a bug report/feature request at
> bugs.python.org.
> 
> Skip




More information about the Python-list mailing list