On 07/09/2014 05:15 PM, Victor Stinner wrote:
2014-07-09 17:29 GMT+02:00 Ben Hoyt <benh...@gmail.com>:
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?

The get_tree_size() function in the PEP would use: "if not
entry.is_symlink() and entry.is_dir():".

Note: First I wrote "if entry.is_dir() and not entry.is_symlink():",
but this syntax is slower on Linux because is_dir() has to call
lstat().

Wouldn't it only have to call lstat if the entry was, in fact, a link?


There are only a few cases where you want to handle symlinks
differently: archive (ex: tar), compute the size of a directory (ex:
du does not follow symlinks by default, du -L follows them), remove a
directory.

I agree with Victor here. If the entry is a link I would want to know if it was a link to a directory or a link to a file. If I care about not following sym links I can check is_symlink() (or whatever it's called).

--
~Ethan~
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to