How to get a directory file descriptor?

greg greg at cosc.canterbury.ac.nz
Wed Nov 26 00:26:58 EST 2008


alex23 wrote:

> import os
> dirfd = os.open("directory-name", os.O_DIRECTORY)
> os.fchdir(dirfd)

os.O_DIRECTORY must be fairly new -- it doesn't exist
in my 2.5 installation. But os.O_RDONLY seems to work
just as well for this purpose.

-- 
Greg



More information about the Python-list mailing list