Python File fileno() Method

Instance

Return the file descriptor of the stream:

f = open("demofile.txt", "r")
print(f.fileno())

Running Instance

Definition and Usage

The fileno() method returns the file descriptor of the stream in numeric form.

An error will occur if the operating system does not use file descriptors.

Syntax

file.fileno()

Parameter Value

No Parameters.