Skip to content
File Methods

tell()

Return the current stream position in the file.

file.tell()

file.tell() returns the current file pointer position as an integer offset from the beginning of the file.

Returns

An integer representing the current byte offset.

Try it

Run it and change it
import tempfile
with tempfile.NamedTemporaryFile(mode='w+', delete=True) as f:
    f.write('Hello')
    print('Position after write:', f.tell())

Worth knowing

  • Tracking progress: Useful for tracking read/write checkpoints, file sizes, or creating bookmarks in structured binary/text streams.

Related entries