Python | os.DirEntry.inode() method Last Updated : 26 Aug, 2019 Comments Improve Suggest changes Like Article Like Report OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality. os.scandir() method of os module yields os.DirEntry objects corresponding to the entries in the directory given by specified path. os.DirEntry object has various attributes and method which is used to expose the file path and other file attributes of the directory entry. inode() method on os.DirEntry object is used to get the inode number of a entry. Note: os.DirEntry objects are intended to be used and thrown away after iteration as attributes and methods of the object cache their values and never refetch the values again. If the metadata of the file has been changed or if a long time has elapsed since calling os.scandir() method. we will not get up-to-date information. Syntax: inode() Parameter: No parameter is required Return type: This method returns an integer value which represents the inode number of the entry. Code: Use of os.DirEntry.inode() method Python3 # Python program to explain os.DirEntry.inode() method # importing os module import os # Directory to be scanned path = os.getcwd() # Using os.scandir() method # scan the specified directory # and yield os.DirEntry object # for each file and sub-directory print("Directory entry name and their inode number") with os.scandir(path) as itr: for entry in itr : # Exclude the entry name # starting with '.' if not entry.name.startswith('.') : # print entry name # and entry's inode() number print(entry.name, " :", entry.inode()) Output: Directory entry name and their inode number Public : 786500 Desktop : 786497 R : 1969824 foo.txt : 801099 graph.cpp : 801237 tree.cpp : 801364 Pictures : 786503 abc.py : 801140 file.txt : 801366 Videos : 786504 images : 1969766 Downloads : 786498 geeksforgeeks : 2097180 Music : 801428 Documents : 786501 References: https://docs.python.org/3/library/os.html#os.DirEntry.inode Comment More infoAdvertise with us Next Article Python | os.DirEntry.inode() method I ihritik Follow Improve Article Tags : Python python-os-module Practice Tags : python Similar Reads Python | os.DirEntry.is_file() method os.DirEntry.is_file() method checks if a directory entry is a regular file. It is used with entries returned by os.scandir(). This method is faster than other file checks because it uses cached system information. It also accepts an optional follow_symlinks parameter that determines whether to follo 2 min read Python | os.DirEntry.is_dir() method os.DirEntry.is_dir() method is used to determine whether a given entry retrieved using os.scandir()) is a directory. It returns True if the entry is a directory and False otherwise. This method is more efficient than manually checking with os.path.isdir() because it can use cached information from t 3 min read Python | os.DirEntry.stat() method OS module in Python provides functions for interacting with the operating system. OS comes under Pythonâs standard utility modules. This module provides a portable way of using operating system dependent functionality. os.scandir() method of os module yields os.DirEntry objects corresponding to the 4 min read Python | os.fsdecode() method OS module in Python provides functions for interacting with the operating system. OS comes under Pythonâs standard utility modules. This module provides a portable way of using operating system dependent functionality. os.fsdecode() method in Python is used to decode the specified filename from the 1 min read Python - os.chdir() method os.chdir() method in Python is used to change the current working directory to the specified path. This function is part of the os module, which provides functionalities to interact with the operating system.Example of os.chdir()Pythonimport os # Check the current working directory print(os.getcwd() 2 min read Like