fileinput.filename() in Python Last Updated : 22 Apr, 2020 Comments Improve Suggest changes Like Article Like Report With the help of fileinput.filename() method, we can get the last used file name which we have used so far by using fileinput.filename() method. Syntax : fileinput.filename() Return : Return the last used file name. Example #1 : In this example we can see that by using fileinput.filename() method, we are able to get the last used file name by using this method. Python3 1=1 # import fileinput import fileinput # Using fileinput.input() method for line in fileinput.input(files ='gfg.txt'): print(line) print(fileinput.filename()) Output : Example #2 : Python3 1=1 # import fileinput import fileinput # Using fileinput.input() method for line in fileinput.input(files =('gfg.txt', 'gfg1.txt')): print(line) print(fileinput.filename()) Output : Comment More infoAdvertise with us Next Article fileinput.filename() in Python J Jitender_1998 Follow Improve Article Tags : Python Python fileinput-library Practice Tags : python Similar Reads fileinput.filelineno() in Python With the help of fileinput.filelineno() method, we can get the line number for every line on line read for every file from input file by using fileinput.filelineno() method. Syntax : fileinput.filelineno() Return : Return the line number for every file. Example #1 : In this example we can see that b 1 min read fileinput.input() in Python With the help of fileinput.input() method, we can get the file as input and can be used to update and append the data in the file by using fileinput.input() method. Python fileinput.input() Syntax Syntax : fileinput.input(files) Parameter : fileinput module in Python has input() for reading from mul 2 min read fileinput.lineno() in Python With the help of fileinput.lineno() method, we can get the line number for every line on line read from input file by using fileinput.lineno() method. Syntax : fileinput.lineno() Return : Return the line number. Example #1 : In this example we can see that by using fileinput.lineno() method, we are 1 min read fileinput.isfirstline() in Python With the help of fileinput.isfirstline() method, we can get the boolean value as True if line read from the file is very first line else false by using fileinput.isfirstline() method. Syntax : fileinput.isfirstline() Return : Return True if line read is first line of that file. Example #1 : In this 1 min read File Mode in Python In Python, the file mode specifies the purpose and the operations that can be performed on a file when it is opened. When you open a file using the open() function, you can specify the file mode as the second argument. Different File Mode in PythonBelow are the different types of file modes in Pytho 5 min read File Handling in Python File handling refers to the process of performing operations on a file such as creating, opening, reading, writing and closing it, through a programming interface. It involves managing the data flow between the program and the file system on the storage device, ensuring that data is handled safely a 7 min read Open a File in Python Python provides built-in functions for creating, writing, and reading files. Two types of files can be handled in Python, normal text files and binary files (written in binary language, 0s, and 1s). Text files: In this type of file, each line of text is terminated with a special character called EOL 6 min read Python | Passing Filenames to Extension in C Filename has to be encoded according to the systemâs expected filename encoding before passing filenames to C library functions. Code #1 : To write an extension function that receives a filename CPP static PyObject* py_get_filename(PyObject* self, PyObject* args) { PyObject* bytes; char* filename; P 2 min read 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 - Get file id of windows file File ID is a unique file identifier used on windows to identify a unique file on a Volume. File Id works similar in spirit to a inode number found in *nix Distributions. Such that a fileId could be used to uniquely identify a file in a volume. We would be using an command found in Windows Command Pr 3 min read Like