The method os.major(device) extracts the device major number from a raw device number (usually the st_dev or st_rdev field from stat).
To use this method, you should have the raw device number. You can use it as follows:
import os, sys path = "/var/www/html/foo.txt" # Now get the stat tuple info = os.lstat(path) # Get major device number major_dnum = os.major(info.st_dev) print "Major Device Number :", major_dnum
This will give the output:
Major Device Number : 0