Re: mimicking a file in memory

2007-12-12 Thread Neil Cerutti
On 2007-12-12, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I found this solution not working. > outfile = StringIO.StringIO() > outfile.write(some_string + '\n') You need to rewind the file with outfile.seek(0) before proceeding, or storlines will encounter an immediate EOF when it attempts to

Re: mimicking a file in memory

2007-12-12 Thread Peter Otten
[EMAIL PROTECTED] wrote: > On Nov 20, 4:37 pm, Jarek Zgoda <[EMAIL PROTECTED]> wrote: > >> Try with StringIO/cStringIO, these modules are supposed to give you >> in-memoryobjects compatible with file object interface. > > I found this solution not working. > I had similar problem: I wanted to wr

Re: mimicking a file in memory

2007-12-12 Thread [EMAIL PROTECTED]
On Nov 20, 4:37 pm, Jarek Zgoda <[EMAIL PROTECTED]> wrote: > Try with StringIO/cStringIO, these modules are supposed to give you > in-memoryobjects compatible with file object interface. I found this solution not working. I had similar problem: I wanted to write some string into the in- memory fi

Re: mimicking a file in memory

2007-11-20 Thread p.
On Nov 20, 3:14 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2007-11-20, p. <[EMAIL PROTECTED]> wrote: > > > > >> By "memory" I presume you mean virtual memory? RAM with > >> disk-blocks as backing store? On any real OS, tempfiles are > >> just RAM with disk-blocks as backing store. > > >> So

Re: mimicking a file in memory

2007-11-20 Thread Grant Edwards
On 2007-11-20, p. <[EMAIL PROTECTED]> wrote: >> By "memory" I presume you mean virtual memory? RAM with >> disk-blocks as backing store? On any real OS, tempfiles are >> just RAM with disk-blocks as backing store. >> >> Sound similar? The only difference is the API used to access >> the bytes. Y

Re: mimicking a file in memory

2007-11-20 Thread Diez B. Roggisch
p. schrieb: > On Nov 20, 2:06 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: >> On 2007-11-20, Jarek Zgoda <[EMAIL PROTECTED]> wrote: >> Here is my dilemma: I don't want to copy the files into a local directory for mutagen's sake, only to have to remove them afterward. Instead, I'd lik

Re: mimicking a file in memory

2007-11-20 Thread p.
On Nov 20, 2:06 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2007-11-20, Jarek Zgoda <[EMAIL PROTECTED]> wrote: > > >> Here is my dilemma: I don't want to copy the files into a > >> local directory for mutagen's sake, only to have to remove > >> them afterward. Instead, I'd like to load the fi

Re: mimicking a file in memory

2007-11-20 Thread Grant Edwards
On 2007-11-20, Jarek Zgoda <[EMAIL PROTECTED]> wrote: >> Here is my dilemma: I don't want to copy the files into a >> local directory for mutagen's sake, only to have to remove >> them afterward. Instead, I'd like to load the files into >> memory and still be able to hand the built-in "file" funct

Re: mimicking a file in memory

2007-11-20 Thread Tim Chase
> I thought about this approach originally, but here's the catch > there: the read method isn't the only method i need. mutagen > calls the seek method on the file object. urllib2 returns a > "file-like object" that does not have a seek method associated > with it, which means i'd have to extend ur

Re: mimicking a file in memory

2007-11-20 Thread Jarek Zgoda
p. pisze: > I am using the mutagen module to extract id3 information from mp3 > files. In order to do this, you give mutagen a filename, which it > converts into a file object using the python built-in "file" function. > > Unfortunately, my mp3 files don't live locally. They are on a number > of r

Re: mimicking a file in memory

2007-11-20 Thread p.
On Nov 20, 1:20 pm, Larry Bates <[EMAIL PROTECTED]> wrote: > p. wrote: > > I am using the mutagen module to extract id3 information from mp3 > > files. In order to do this, you give mutagen a filename, which it > > converts into a file object using the python built-in "file" function. > > > Unfortu

Re: mimicking a file in memory

2007-11-20 Thread Larry Bates
p. wrote: > I am using the mutagen module to extract id3 information from mp3 > files. In order to do this, you give mutagen a filename, which it > converts into a file object using the python built-in "file" function. > > Unfortunately, my mp3 files don't live locally. They are on a number > of r

mimicking a file in memory

2007-11-20 Thread p.
I am using the mutagen module to extract id3 information from mp3 files. In order to do this, you give mutagen a filename, which it converts into a file object using the python built-in "file" function. Unfortunately, my mp3 files don't live locally. They are on a number of remote servers which I