File objects? - under the hood question

Jeremy Bowers jerf at
Wed Jan 19 03:24:11 EST 2005

On Tue, 18 Jan 2005 22:53:10 -0800, Eric Pederson wrote:
> Perhaps I've answered my question and the under-the-hood mechanics are
> handled on the OS side, and Python is just making requests of the OS...

Almost by definition, the only correct way to read a file is to use the
file system, which on current operating systems means going the the OS

> My brain-teaser:  What I'd like to do is read the last ~2K of a large
> number of large files on arbitrary servers across the net, without having
> to read each file from the beginning (which would be slow and resource
> inefficient)...

"Across the net" is not specific enough. There are generally ways to do
that, subject to the support of the various relevant servers, but what
protocol are you talking about using? HTTP? FTP? NFS? Generally you issue
some sort of command to get the length, then some sort of "seek" or
"continuation" command to get to the end, but the details are different
for each protocol. (Unless someone has a convenient flattening library
around? I have something almost like that in my personal collection except
I have no intention of supporting "seek" behavior for various technical

And note that with the possible exception of that last one, there is no
relationship between these two questions. (Maybe you know that, maybe you
don't. :-) ) There is no argument you can pass to file() that will read an
HTTP file. (Pedants may note this isn't an absolute truth but it's "true
enough" that it's not worth sweating the details if you're still working
out what "file()" does.)

More information about the Python-list mailing list