Python method isatty()returns True if the file descriptor fd is open and connected to a tty(-like) device, else False.
Following is the syntax for isatty() method:
os.isatty( fd )
This method returns True if the file descriptor fd is open and connected to a tty(-like) device, else False.
The following example shows the usage of isatty() method.
#!/usr/bin/python import os, sys # Open a file fd = os.open( "foo.txt", os.O_RDWR'os.O_CREAT ) # Write one string os.write(fd, "This is test") # Now use isatty() to check the file. ret = os.isatty(fd) print "Returned value is: ", ret # Close opened file os.close( fd )
When we run the above program, it produces the following result:
Returned value is: False
Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.