[Python-Dev] Updates to PEP 471, the os.scandir() proposal (original) (raw)
Paul Moore p.f.moore at gmail.com
Wed Jul 9 17:26:48 CEST 2014
- Previous message: [Python-Dev] Updates to PEP 471, the os.scandir() proposal
- Next message: [Python-Dev] Updates to PEP 471, the os.scandir() proposal
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 9 July 2014 16:05, Victor Stinner <victor.stinner at gmail.com> wrote:
The PEP says that DirEntry should mimic pathlib.Path, so I think that DirEntry.isdir() should work as os.path.isir(): if the entry is a symbolic link, you should follow the symlink to get the status of the linked file with os.stat().
Would this not "break" the tree size script being discussed in the other thread, as it would follow links and include linked directories in the "size" of the tree?
As a Windows user with only a superficial understanding of how symlinks should behave, I don't have any intuition as to what the "right" answer should be. But I would say that the tree size code we've been debating over there (which recurses if is_dir is true and adds in st_size otherwise) should do whatever people would expect of a function with that name, as it's a perfect example of something a Windows user might write and expect it to work cross-platform. If it doesn't much of the worrying over making sure scandir's API is "cross-platform by default" is probably being wasted :-)
(Obviously the walk_tree function could be modified if needed, but that's missing the point I'm trying to make :-))
Paul
- Previous message: [Python-Dev] Updates to PEP 471, the os.scandir() proposal
- Next message: [Python-Dev] Updates to PEP 471, the os.scandir() proposal
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]