×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

Home » Python

Python File seekable() Method with Example

Python File seekable() Method: Here, we are going to learn about the seekable() method, how to check whether a file is seekable or not in Python?
Submitted by IncludeHelp, on December 22, 2019

File seekable() Method

seekable() method is an inbuilt method in Python, it is used to check whether a file stream is seekable or not in Python?

Syntax:

    file_object.seekable()

Parameter(s):

  • It does not accept any parameter.

Return value:

The return type of this method is <class 'bool'>, it returns True if file stream is seekable and returns False if files is not seekable.

Example:

# Python File seekable() Method with Example

# creating a file
myfile1 = open("hello1.txt", "w")

# checking whethet the file stream is 
# seekable or not
print("myfile1.seekable():", myfile1.seekable())

# closing the file
myfile1.close()

# opening file in read mode
myfile1 = open("hello1.txt", "r")

# checking whethet the file stream is 
# seekable or not
print("myfile1.seekable():", myfile1.seekable())

# closing the file
myfile1.close()

Output

myfile1.seekable(): True
myfile1.seekable(): True
Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.