[Python-Dev] PEP 471: scandir(fd) and pathlib.Path(name, dir_fd=None)

Charles-François Natali cf.natali at gmail.com
Wed Jul 2 19:20:41 CEST 2014

> 2014-07-02 12:51 GMT+02:00 Charles-François Natali <cf.natali at gmail.com>:
>> I don't think we should support it: it's way too complicated to use,
>> error-prone, and leads to messy APIs.
> Can you please elaborate? Which kind of issue do you see? Handling the
> lifetime of the directory file descriptor?

Yes, among other things. You can e.g. have a look at os.fwalk() or
shutil._rmtree_safe_fd() to see that using those *properly* is far
from being trivial.

> You don't like the dir_fd parameter of os functions?

Exactly, I think it complicates the API for little benefit (FWIW, no
other language I know of exposes them).

More information about the Python-Dev mailing list