YouTip LogoYouTip

Os Makedev

# Python2.x Python os.makedev() Method [![Image 3: Python File Methods](#) Python OS File/Directory Methods](#) * * * ### Overview The os.makedev() method is used to compose a raw device number from 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/python# -*- coding: UTF-8 -*-import os, sys path = "/var/www/html/foo.txt"# Get tuple 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 # Generate device number dev_num = os.makedev(major_dnum, minor_dnum)print "Device number :", dev_num The output of executing the above program is: Major Device number : 0Minor Device number : 103Device number : 103 [![Image 4: Python File Methods](#) Python OS File/Directory Methods](#)
← Rust File IoPr Object Fit β†’