YouTip LogoYouTip

File Isatty

# Python2.x Python File isatty() Method [![Image 3: Python File Methods](#) Python File Methods](#) * * * ### Overview The **isatty()** method checks whether the file is connected to a terminal device, returning True if it is, and False otherwise. ### Syntax The syntax of the isatty() method is as follows: fileObject.isatty(); ### Parameters * **None** ### Return Value Returns True if connected to a terminal device, otherwise returns False. ### Example The following example demonstrates the use of the isatty() method: #!/usr/bin/python# -*- coding: UTF-8 -*-# Open file fo = open(".txt", "wb")print "File name is: ", fo.name ret = fo.isatty()print "Return Value : ", ret # Close file fo.close() The output of the above example is: File name is: .txt Return Value : False
← File IsattyLinux Comm Liloconfig β†’