Python File isatty() Method
Advertisements
Description
The method isatty() return True if the file is connected (is associated with a terminal device) to a tty(-like) device, else False.
Syntax
Following is the syntax for isatty() method
fileObject.isatty();
Parameters
NA
Return Value
This method return true if the file is connected (is associated with a terminal device) to a tty(-like) device, else false.
Example
The following example shows the usage of isatty() method.
#!/usr/bin/python
# Open a file
fo = open("foo.txt", "wb")
print "Name of the file: ", fo.name
ret = fo.isatty()
print "Return value : ", ret
# Close opend file
fo.close()
Let us compile and run the above program, this will produce the following result:
Name of the file: foo.txt Return value : False