Alternative to os.listdir()/os.stat()

nobody nobody at nowhere.near.here
Thu Jan 23 07:40:35 EST 2003


Also os.path.walk() could be an improvement.

"Alfredo P. Ricafort" <alpot at mylinuxsite.com> wrote in message
news:mailman.1043304821.26500.python-list at python.org...
> Hi,
>
> I'm trying to get the files under a directory and its details. What  I
> did is to call os.listdir() and then os.stat(). So my code looks
> something like this:
>
>
>     fileList=os.listdir(path)
>     for i in range(len(fileList)):
>         f=os.stat(path+'/'+j)
>
> However, I noticed that this approach takes a long time when the
> directory contains lots of files. So what I am looking for now is a
> function that can give me the details is one go, much like 'ls -ltra' in
> UNIX.
>
> Does one exists?
>
> AL
>
>






More information about the Python-list mailing list