The current position of the file read/write pointer within the file returned by the tell() method.
grammatical
The following is the syntax of the tell() method:
()
parameters
- NA
return value
This method returns the current position of the file/write pointer read from this file.
(for) instance
The following example shows the use of the tell() method.
#!/usr/bin/python # Open a file fo = open("", "rw+") print "Name of the file: ", # Assuming file has following 5 lines # This is 1st line # This is 2nd line # This is 3rd line # This is 4th line # This is 5th line line = () print "Read Line: %s" % (line) # Get the current position of the file. pos = () print "Current Position: %d" % (pos) # Close opend file ()
When we run the above program, it produces the following results:
Name of the file: Read Line: This is 1st line Current Position: 18