How to get a directory file descriptor?

Cong Ma cma at mail.bnu.edu.cn
Tue Nov 25 22:34:20 EST 2008


alex23 wrote:
> On Nov 26, 12:31 am, "D'Arcy J.M. Cain" <da... at druid.net> wrote:
>> Is this what you want?
>>
>> ofiles = [open(x) for x in os.listdir(os.getcwd())]
> 
> 'open' returns a "file object", whereas the OP is after "file
> descriptors", which are returned by 'os.open'.
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
You got it.

So if I can't seem to get directory file descriptors, the only way to use
os.fchdir() in Python is to embed Python in C code?




More information about the Python-list mailing list