Re: [Tutor] re-reading file-like objects

2006-10-09 Thread Kent Johnson
Tiago Saboga wrote: > I'm afraid I don't fully understand file objects. I thought I could use it > just as a file: if I have one, and I want several copies, I just save it with > several names. So, if Popen.stdout already is a file object, I thought the > easier way would be to save it with anot

Re: [Tutor] re-reading file-like objects

2006-10-09 Thread Alan Gauld
> For this simple example, this solution is fine, and I think the > solution > proposed by Alan (StringIO) is not going to add anything. Would it > be faster? Probably not, the StringIO solution is just closer to how you described the problem, but also provides a fuller set of file-like method

Re: [Tutor] re-reading file-like objects

2006-10-09 Thread Tiago Saboga
Em Segunda 09 Outubro 2006 10:41, Kent Johnson escreveu: > Tiago Saboga wrote: > > Hi! > > > > I have a problem with file-like objects for months now, and I hoped I > > could cope with it, but I keep using what seems to me like a newbie > > workaround... > > > > The question is: how can I read a fi

Re: [Tutor] re-reading file-like objects

2006-10-09 Thread Alan Gauld
> because it reads the file with read() method, which can only be used > once. If > it's a real file, on disk, I agree it would not be a clever > strategy, reading > it once for each copy, and I would be happy keeping its content in a > variable. But if the file is in memory, why can't I simply r

Re: [Tutor] re-reading file-like objects (SOLVED?)

2006-10-09 Thread Kent Johnson
Tiago Saboga wrote: > But I strip the code, and post a new one. The solution I found is in the > seek() method of the file object. And the problem I had is that not all the > file-like objects have a functional seek() method. It's not the case for the > object referenced by the stdout attribute

Re: [Tutor] re-reading file-like objects

2006-10-09 Thread Kent Johnson
Tiago Saboga wrote: > Hi! > > I have a problem with file-like objects for months now, and I hoped I could > cope with it, but I keep using what seems to me like a newbie workaround... > > The question is: how can I read a file (more precisely, a file-like object) > more than one single time? >

Re: [Tutor] re-reading file-like objects (SOLVED?)

2006-10-09 Thread Tiago Saboga
I keep the original question: Em Segunda 09 Outubro 2006 09:21, Tiago Saboga escreveu: > Hi! > > I have a problem with file-like objects for months now, and I hoped I could > cope with it, but I keep using what seems to me like a newbie workaround... > > The question is: how can I read a file (mor

[Tutor] re-reading file-like objects

2006-10-09 Thread Tiago Saboga
Hi! I have a problem with file-like objects for months now, and I hoped I could cope with it, but I keep using what seems to me like a newbie workaround... The question is: how can I read a file (more precisely, a file-like object) more than one single time? In the following example, I want t