Filehandling/processing in Python

Gordon McMillan gmcm at hypernet.com
Mon Oct 11 08:27:49 EDT 1999


Thomas Weholt asks:

> It seems like file-handling, ie. more than reading lines in a
> plain-text file, is done by 3rd-party modules in Python. I`ve
> looked into os.stat-module, but I`d like know what
> methods/functions are available, and most importantly, how to
> handle the returned values. Isn`t there somebody who has worked
> on this earlier, like made a ls/dir-like command that lists out
> files and modification time, size, type ( file or dir ) etc?
> 
> Most of my scripts dive into folders and process them
> recursively, so this is rather important to me, but my Python
> books ( Learning Python, Programming Python and Internet
> Programming with Python ) don`t seem to go beyond the old
> input.readline() stuff.

You probably have an older version of the docs, where this 
stuff is hard to find. What you're looking for is all available 
under os and os.path (particularly os.path.walk for recursive 
handling of directories). Unless you have the current docs, this 
is under "posix" and "posixpath".

- Gordon




More information about the Python-list mailing list