Tell function in python with example
Tell () function can be used to get the position of file handle and returns current position of file object where as Seek () function is used to change the position of the file handle to a given specific position in python. File handle such as a cursor which defines from where the data has to be read or written in the file.
Tell function takes no parameters and returns an integer value. Initially file pointer points to be beginning of the file. So the initial value of tell () is zero.
In other words we can say that tell () function is all about the returning of the current file position in a file stream. We can also change the current position by using seek () function.
Syntax: fileobj.tell ()
fileobj=open (“careerbodh.txt”, “r”)
print(“File Position: “,fileobj.tell())
print(“First lin : “, fileobj.readline())
print(“File Position :”, fileobj.tell())
print(“Second line:”, fileobj.readline())
print(“File Position:”, fileobj.tell())
File Position: 0
First line: Career Bodh Sansthan
File Position: 7
Second line: Career Bodh CCC
File Position: 13