How to get a directory file descriptor?
cma at mail.bnu.edu.cn
Tue Nov 25 09:02:56 CET 2008
> Cong Ma wrote:
>> Dear all,
>> Can you give me some hint on getting a directory file descriptor in Python?
>> Besides, what's good about os.fchdir() if I can't get a directory fd in the
>> first place?
>> Thanks for your reply.
> for each in os.listdir(os.getcwd()):
> print each
It seemed I didn't make it clearly enough...
Your code fetches a bunch of strings representing file names in the working
directory, which is fine. But what I want is something like an integer file
descriptor, like the one returned by os.open() for files, or the Linux dirfd()
call, which returns an integer for a pointer to a DIR stream.
More information about the Python-list