How to get the minor and major device numbers with os.stat ?

Martin v. Loewis martin at
Mon Oct 21 07:49:30 CEST 2002

Grant Edwards <grante at> writes:

> AFAIK, os.stat() has never returned device number info.
> Last time I looked, the posix stat wrapper doesn't do anyting
> with the st_rdev field.  [Don't know why -- it sure would be
> useful sometimes.]

This is not true anymore: os.stat("device").st_rdev returns the
st_rdev field since Python 2.2.

Adding this field was not possible before since it would mean to
extend the length of the tuple, which in turn would have meant to
break code which does tuple-unpacking on stat results.

Python 2.3 will also add wrappers for the major and minor macros.


More information about the Python-list mailing list