On Tue, 25 Nov 2008 16:02:56 +0800
Cong Ma <[EMAIL PROTECTED]> wrote:
> >> Can you give me some hint on getting a directory file descriptor in Python?
> > for each in os.listdir(os.getcwd()):
> >   print each
> 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.

Is this what you want?

ofiles = [open(x) for x in os.listdir(os.getcwd())]

-- 
D'Arcy J.M. Cain <[EMAIL PROTECTED]>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to