How to get a directory file descriptor?

r0g aioe.org at technicalbloke.com
Tue Nov 25 03:45:20 EST 2008


r0g wrote:
> Cong Ma wrote:
>> r0g wrote:
>>> 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.
>>>>
>>>> Regards,
>>>> Cong.
>>>>
>>> for each in os.listdir(os.getcwd()):
>>>   print each
>>>
>>> Roger.
>>> --
>>> http://mail.python.org/mailman/listinfo/python-list
>>>
>> Roger,
>>
>> 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.
>>
>> Regards,
>> Cong.
>>
> 
> Erm, yeah, that's the os.listdir() bit.
> 
> Roger.

Actually, just re-reading your last mail, it isn't what you want at all
is it?! Sorry!

Roger.



More information about the Python-list mailing list