On Fri, Jul 26, 2019 at 3:54 AM eryk sun <eryk...@gmail.com> wrote: > > On 7/25/19, Chris Angelico <ros...@gmail.com> wrote: > > On Fri, Jul 26, 2019 at 3:28 AM eryk sun <eryk...@gmail.com> wrote: > >> > >> On 7/25/19, Kirill Balunov <kirillbalu...@gmail.com> wrote: > >> > > >> >>>> import os > >> >>>> from pathlib import Path > >> >>>> dummy = " " # or "" or " " > >> >>>> os.path.isdir(dummy) > >> > False > >> >>>> Path(dummy).is_dir() > >> > True > >> > >> I can't reproduce the above result in either Linux or Windows. The > >> results should only be different for an empty path string, since > >> Path('') is the same as Path('.'). The results should be the same for > >> Path(" "), depending on whether a directory named " " exists (normally > >> not allowed in Windows, but Linux allows it). > > > > Try an empty string, no spaces. To pathlib.Path, that means the > > current directory. To os.path.abspath, that means the current > > directory. To os.stat, it doesn't exist. > > That's what I said. But the OP shows os.path.isdir(" ") == False and > Path(" ").is_dir() == True, which is what I cannot reproduce and > really should not be able to reproduce, unless there's a bug > somewhere.
Yeah but WHY is it different for an empty string? I can well imagine that some OS/FS combinations will happily strip spaces, thus devolving the " " case to the "" one. ChrisA -- https://mail.python.org/mailman/listinfo/python-list