English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Python basic tutorial

Python flow control

Fonctions en Python

Types de données en Python

Python file operations

Python objects and classes

Python date and time

Advanced knowledge of Python

Python reference manual

Python file isatty() usage and examples

Python File (file) methods

Overview

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

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:

# Open the file
fo = open("w3codebox.txt, "wb")
print("File name: ", fo.name)
ret = fo.isatty()
print("Return value: ", ret)
# Close the file
fo.close()

The output result of the above example is as follows:

File name: w3codebox.txt
Return value: False

Python File (file) methods