[Baypiggies] stat.ST_BLKSIZE?

Guido van Rossum guido at python.org
Sun Jan 22 02:34:21 CET 2006


On 1/21/06, Chris Palmer <chris at noncombatant.org> wrote:
> Hi there, I've got a random question. Why doesn't os.stat return the
> filesystem's block size? Is there some other way to find that out in
> Python? Googling the obvious ("python stat block size", "python stat
> st_blksize") didn't reveal anything. Thanks.

Doesn't this work for you? It works for me (Linux Red Hat, version 7.2 or so.)

$ python2.2
Python 2.2.3+ (#94, Jun  4 2003, 08:24:18)
[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-113)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
[startup.py ...]
[startup.py done]
>>> import os
>>> os.stat(".").st_blksize
4096
>>>

The value doesn't get returned as part of the 10-tuple, but it is
available through the (newer) attribute-based API, as long as the
underlying OS makes st_blksize available in its struct stat.

--
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Baypiggies mailing list