Eastwooder
Eastwooder

Reputation: 28

python: read beyond end of file

I'm trying to read beyond the EOF in Python, but so far I'm failing (also tried to work with seek to position and read fixed size).

I've found a workaround which only works on Linux (and is quite slow, too) by working with debugfs and subprocess, but this is to slow and does not work on windows.

My Question: is it possible to read a file beyond EOF in python (which works on all platforms)?

Upvotes: 0

Views: 2636

Answers (2)

turkus
turkus

Reputation: 4903

You can only move to the end using:

file.seek(0, 2)

Is that you're trying to do?

Upvotes: 1

Bryan Oakley
Bryan Oakley

Reputation: 386332

You can't read more bytes than is in the file. "End of file" literally means exactly that.

Upvotes: 5

Related Questions