Python - File seekable() Method


Advertisements

The Python file seekable() method is used to check whether the file is seekable or not. It returns true when the file is seekable, else returns false. A file is seekable if it allows access to the file stream, like the seek() method.

Syntax


file.seakable()

Parameters

No parameter is required.

Example:

In the below example, the file seekable() method is used on file called MyFile which is a seekable file, hence it returns True.

MyFile = open("python_test.txt", "r")

print(MyFile.seekable())

Output

True

Python File Handling Methods
Advertisements