[Python-Dev] Remaining decisions on PEP 471 -- os.scandir()
ncoghlan at gmail.com
Mon Jul 14 04:17:33 CEST 2014
On 13 Jul 2014 20:54, "Tim Delaney" <timothy.c.delaney at gmail.com> wrote:
> On 14 July 2014 10:33, Ben Hoyt <benhoyt at gmail.com> wrote:
>> If we go with Victor's link-following .is_dir() and .is_file(), then
>> we probably need to add his suggestion of a follow_symlinks=False
>> parameter (defaults to True). Either that or you have to say
>> "stat.S_ISDIR(entry.lstat().st_mode)" instead, which is a little bit
>> less nice.
> Absolutely agreed that follow_symlinks is the way to go, disagree on the
>> Given the above arguments for symlink-following is_dir()/is_file()
>> methods (have I missed any, Victor?), what do others think?
> I would say whichever way you go, someone will assume the opposite. IMO
not following symlinks by default is safer. If you follow symlinks by
default then everyone has the following issues:
> 1. Crossing filesystems (including onto network filesystems);
> 2. Recursive directory structures (symlink to a parent directory);
> 3. Symlinks to non-existent files/directories;
> 4. Symlink to an absolutely huge directory somewhere else (very annoying
if you just wanted to do a directory sizer ...).
> If follow_symlinks=False by default, only those who opt-in have to deal
with the above.
Or the ever popular symlink to "." (or a directory higher in the tree).
I think os.walk() is a good source of inspiration here: call the flag
"followlink" and default it to False.
> Tim Delaney
> Python-Dev mailing list
> Python-Dev at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev