A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/python/os_minor.htm below:

Python os.minor() Method

Python os.minor() Method

The Python os.minor() method extracts the device minor number from a raw device number. This raw device number is obtained by either "st_dev" or "st_rdev" field of "os.stat_result" object returned by os.stat() method.

The os.stat() method is used to get the status of file descriptor.

NOTE: In Unix-like operating systems, every file is associated with a device number. This number is composed of two parts namely major and minor. The major number specifies the driver associated with the device, whereas the minor number is used by the driver to differentiate between different devices it controls.

Syntax

Following is the syntax for Python os.minor() method −

os.minor(device)
Parameters

The Python os.minor() method accepts only one parameter −

Return Value

The Python os.minor() method returns the device minor number.

Example

The following example shows the usage of minor() method. Here, we are retrieving the minor device number from the value obtained by "st_dev" attribute.

import os, sys

path = "/home/tp/Python/nwdir/tmpFile.txt"

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

# Get minor device number
minor_dnum = os.minor(info.st_dev)
print ("Minor Device Number :", minor_dnum)

When we run above program, it produces following result −

Minor Device Number : 3
Example

In this example, we are extracting the minor device number of a file descriptor from the value obtained by "st_rdev" attribute.

import os
import stat

# path of terminal character device
deviceStat = os.stat("/home/tp/Python/tmp/new").st_rdev
mNumber = os.minor(deviceStat)
print(f"The minor device number: {mNumber}")

On executing the above program, it produces the following output −

The minor device number: 0

python_files_io.htm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4