Python3 Os Isatty
# Python3.x Python3 os.isatty() Method
[ Python3 OS File/Directory Methods](#)
* * *
### Overview
The os.isatty() method is used to check if the file descriptor fd is open and connected to a tty(-like) device. It returns true if it is, otherwise false.
### Syntax
The syntax for the **isatty()** method is as follows:
os.isatty()
### Parameters
* None
### Return Value
Returns true if the file descriptor fd is open and connected to a tty(-like) device, otherwise false.
### Example
The following example demonstrates the use of the isatty() method:
#!/usr/bin/python3import os, sys # Open a file fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT )# Write a string str = "This is site" os.write(fd,bytes(str, 'UTF-8'))# Use isatty() to check the file ret = os.isatty(fd)print ("Return value: ", ret)# Close the file os.close( fd )
The output of executing the above program is:
Return value: False
[ Python3 OS File/Directory Methods](#)
YouTip