I've tried using the path module and it works like a *charm*.. plus my
code is cleaner and clearer.. :)
The list comprehension using os.stat() works well though I had to call
an additional reverse() on the resultant list so that I could get the
list in order of "newest first".
So, in conclusion
Just to clarify:
Newest== modified last
The processing\sorting should apply to all the files found recursively
during the entire walk.
That being said, thanks for all the responses. I'll test the code
shortly and get back to everyone.
ps. This is why comp.lang.python is truly the greatest list
"Peter Hansen" <[EMAIL PROTECTED]> wrote:
> yoda wrote:
> > This feels like a stupid question but I'll ask it anyway.
> >
> > How can I process files chronologically (newest last) when using
> > os.walk()?
>
> Do you want the ordering to apply just to files within each directory,
> or to all the f
yoda wrote:
>This feels like a stupid question but I'll ask it anyway.
>
>
Definitely not a stupid question.
>How can I process files chronologically (newest last) when using
>os.walk()?
>
>
>
Try this:
In [16]: file_list = [(os.stat(f)[8], f) for f in [os.path.join(i[0],
j) for i in os.w
untested, ugly, but something like this would sort all the files in the
directory on os.path.getctime (not using os.walk() though). I'm sure
there is probably better ways to do it :)
filelist = []
def walkdir(currdir):
for files in os.listdir(currdir):
path = os.path.join(currdir, fil
yoda wrote:
> This feels like a stupid question but I'll ask it anyway.
>
> How can I process files chronologically (newest last) when using
> os.walk()?
Do you want the ordering to apply just to files within each directory,
or to all the files found (recursively) during the entire walk? Define
This feels like a stupid question but I'll ask it anyway.
How can I process files chronologically (newest last) when using
os.walk()?
--
http://mail.python.org/mailman/listinfo/python-list