os.walk()

Chris Rebert clp2 at rebertia.com
Tue Aug 4 22:48:45 EDT 2009


On Tue, Aug 4, 2009 at 7:06 PM, Michael Savarese<geomajor56 at gmail.com> wrote:
> Greetings
> Python newbie here, and thanks to all who have helped me previously.
> Is there a way of grabbing file attributes while traversing with os.walk()?
> It would be advantageous to have date modified and file size along with the
> file name.
> If anyone can point me in the right direction, I'd appreciate it.

Feed the path to os.stat(), and then use the `stat` module on the result:
http://docs.python.org/library/os.html#os.stat
http://docs.python.org/library/stat.html#module-stat

Cheers,
Chris
-- 
http://blog.rebertia.com



More information about the Python-list mailing list