EOF for binary?
Roy Smith
roy at panix.com
Fri Jan 7 20:43:03 EST 2005
In article <1105147072.909665.242360 at z14g2000cwz.googlegroups.com>,
"flamesrock" <flamesrock at gmail.com> wrote:
> Hi,
>
> So if I understand correctly, there are NO eof characters in any binary
> file. If so, is there an easier way to check for the end of the file
> than:
>
> os.path.getsize(infile) <= infile.tell()
How you detect EOF depends on how you're reading the file. For example,
read() indicates EOF by returning fewer characters than you asked for
(possibly zero).
Checking the length of a file is perilous. Files change size. File
sizes don't have much meaning on things like network sockets to begin
with.
More information about the Python-list
mailing list