This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lucas_malor
Recipients
Date 2007-04-27.09:26:35
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
If you don't want the intere file on your memory, there's two solutions:

----------
import urllib

urlobj = urllib.urlopen("someurl")
header = urlobj.read(1)
# some other operations (no other urlobj.read())

contents = header + urlobj.read()

----------

I don't think it's a --good-- solution, because some other programmers can do other read() operations and mess all the result.

The other solution is:

----------
def readall(x) :
  url = x.geturl
  x.close()
  try :
    y = urllib.openurl(url)
  except :
    return None
  return y.read()
  

import urllib

urlobj = urllib.urlopen("someurl")
header = urlobj.read(1)
# some other operations

contents = readall(urlobj)

----------

This is still a bad solution (two calls to the server for the same file).

On the contrary I'm pretty sure using a sequencial access this can be done without doing these workarounds.

(anyway I don't understand a thing: HTTP can't delegate the server to seek() the file?)
History
Date User Action Args
2007-08-23 14:52:32adminlinkissue1682241 messages
2007-08-23 14:52:32admincreate