[Tutor] Re: Getting "file sizes" !Sovled!! For real.. Heh..Heh..

Joshua Banks syn_ack at comcast.net
Thu Feb 26 13:39:32 EST 2004


I'll actually start a new thread for my os.walk confusion. Thanks Blake. I'm
pretty busy too. Sorry for being on the lazy side. All my free time is spent
reading Python documentation. So any little pointers help of which you've
helped allot. The code example worked for the most part. Although it only
went one layer deeper into the given directory structure. Thats cool though.
This is helping me get my brain to start thinking differently about
programming.

Thanks again,
Joshua Banks
----- Original Message ----- 
From: "Blake Winton" <bwinton at latte.ca>
> I can give you this modification to your example, though:

> > import os, os.path
> > dirname = "c:\\Documents and Settings\\jj\\Desktop\\"
> > a = os.listdir(dirname)
> > for x in a:
> >     print x, os.path.getsize(dirname + x)
>
> import os, os.path
> dirname = "c:\\Documents and Settings\\jj\\Desktop\\"
> a = os.listdir(dirname)
> for x in a:
>     fullPath = os.path.join( dirname, x );
>     if os.path.isdir( fullPath ):
>         b = os.listdir( fullPath )
>         for y in b:
>             fullSubPath = os.path.join( dirname, x, y )
>             print x, "->" , y, os.path.getsize( fullSubPath )
>     print x, os.path.getsize( os.path.join( dirname, x ) )
>
> does that help at all?
>
> Later,
> Blake.
>




More information about the Tutor mailing list