You are here : python_2ososmajor

os.major() - os

             

The method major() extracts the device major number from a raw device number (usually the st_dev or st_rdev field from stat).


  • device -- This is a raw device number (usually the st_dev or st_rdev field from stat).


Syntax


os.major(device)


Example


#!/usr/bin/python

import os, sys

path = "/var/www/html/foo.txt"

# Now get  the touple
info = os.lstat(path)

# Get major and minor device number
major_dnum = os.major(info.st_dev)
minor_dnum = os.minor(info.st_dev)

print "Major Device Number :", major_dnum
print "Minor Device Number :", minor_dnum


Output / Return Value

When we run above program, it produces following result:


Major Device Number : 0 Minor Device Number : 103


Limitations


Alternatives / See Also


Reference