[Tutor] Getting "file sizes" (fwd)
dyoo at hkn.eecs.berkeley.edu
Fri Mar 25 05:14:36 CET 2005
---------- Forwarded message ----------
Date: Wed, 18 Feb 2004 16:44:49 -0800
From: Joshua Banks <syn_ack at comcast.net>
To: slyskawa at gmail.com
Cc: Danny Yoo <dyoo at hkn.eecs.berkeley.edu>
Subject: Re: [Tutor] Getting "file sizes"
On Wednesday 18 February 2004 01:22 pm, you wrote:
> Ah, a Gentoo fan. *grin*
Yes, I luv Gentoo... :P
> Ah, you know about os.path.getsize() already then. getsize() is
> actually more versatile than you might think: have you tried applying
> it on an individual file path?
Yes, I can get the file size of an individual file by specifying the
complete path. But if I have a directory with 60 files then I would
have to manually put the path in for each file in that directory that I
wish to know the size of.
Example: The following gives me a list of the files in the directory
specified below. There's a total of 12 files listed for examples sake.
'1757-gentoo-sources-2.4.22-r5.log', '1788-tcl-8.3.4.log', '1797-libpe
rl-5.8.0.log', '1769-python-2.3.3.log', '1776-xfree-drm-4.3.0-r6.log',
I also understand that I can do the following 12 times, specifying a
different file each time and get the "file size answers that I'm
looking for. So I understand how to do this the HardWay.
What I don't understand is how to get Python to use the "getsize()"
function for each file that the "os.listdir('/var/log/portage')"
I've read and read and read. I don't understand, what seems, would be a
simple task. Having to manually input each file, one at a time seems
backwards to the progamming moto. Do more with less so to say.
I'm I not making any sense? Any idea's on how I can get this to work?
Tutor maillist - Tutor at python.org
More information about the Tutor