Easy Tutorial
❮ Python String Strip Python Smtp ❯

Python3 os.makedev() Method

Python3 OS File/Directory Methods


Overview

The os.makedev() method is used to compose a raw device number from the major and minor device numbers.

Syntax

The syntax for the makedev() method is as follows:

os.makedev(major, minor)

Parameters

-

major -- Major device number.

-

minor -- Minor device number.

Return Value

Returns the device number.

Example

The following example demonstrates the use of the makedev() method:

#!/usr/bin/python3

import os, sys

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

# Get the tuple
info = os.lstat(path)

# Get the major and minor device numbers
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)

# Generate the device number
dev_num = os.makedev(major_dnum, minor_dnum)
print("Device Number :", dev_num)

Executing the above program outputs:

Major Device Number : 0
Minor Device Number : 103
Device Number : 103

Python3 OS File/Directory Methods

❮ Python String Strip Python Smtp ❯