get output of du / ls command - currently ugly code ...

Esmail ebonak at hotmail.com
Thu Aug 13 17:32:34 EDT 2009


Albert Hopkins wrote:
> 
> I don't know about "easier", but a more elegant way is to not use
> os.popen() and to use Python's functions os.path.getsize (or os.stat)
> and os.walk (or os.path.walk) to achieve this.
> 
> In fact if you look at the docstring for os.walk there is an example
> that almost does what you're doing with du, but is cross-platform and
> not dependent on shelling a process and scraping its stdout.

Thanks Albert, I'll take a look,

Esmail




More information about the Python-list mailing list