Easy Tutorial
❮ Python Os Makedirs Python Att Dictionary Get ❯

Python3 File isatty() Method

Python3 File Methods


Overview

The isatty() method checks if the file is connected to a terminal device. It returns True if connected, otherwise False.

Syntax

The syntax for the isatty() method is as follows:

fileObject.isatty();

Parameters

-

None

Return Value

Returns True if connected to a terminal device, otherwise False.

Example

The following example demonstrates the use of the isatty() method:

#!/usr/bin/python3

# Open file
fo = open("tutorialpro.txt", "wb")
print("File name: ", fo.name)

ret = fo.isatty()
print("Return value: ", ret)

# Close file
fo.close()

The output of the above example is:

File name:  tutorialpro.txt
Return value:  False

Python3 File Methods

❮ Python Os Makedirs Python Att Dictionary Get ❯