Dreaded Newbie Question
Gary Herron
gherron at aw.sgi.com
Thu Jul 22 20:52:21 EDT 1999
Dani Epstein wrote:
>
> Hi!
>
> A newbie to Python (though currently coding in Delphi), I'm having a
> little difficulty tracking down stuff, although I have the tutorial and
> manuals. Where is the best place to get more info, and why is there no
> newsgroup for newbies like myself?
>
> For the moment though my grateful thanks goes to anyone who can tell me
> how to get a file's size, and where that info is to be found in the
> references.
>
> BTW, I'm running PythonWin 1.5.1
> --
>
> Dani Epstein
Use os.stat to get a tuple of information about the file. The item at
index 6 (symbolically stat.ST_SIZE) is the size in bytes. The value is
an integer (or a long integer) depending on the particular os.
>>> import os, stat
>>> os.stat('.login')
(33188, 30804640L, 33554464, 1, 27117, 20, 620L, 932451656, 797807295,
925402414)
>>> os.stat('.login')[stat.ST_SIZE]
620L
Documentation is in the "Module os" section.
--
Dr. Gary Herron <gherron at aw.sgi.com>
206-287-5616
Alias | Wavefront
1218 3rd Ave, Suite 800, Seattle WA 98101
More information about the Python-list
mailing list