Kent, Thanks! I think that'll do it. I don't know what this list would do without you!
-Modulok- On 12/27/09, Kent Johnson <ken...@tds.net> wrote: > On Sun, Dec 27, 2009 at 3:36 AM, Modulok <modu...@gmail.com> wrote: >> List, >> >> How do I create a file which exists only in memory? (Think diskless.) >> >> I need to create an in-memory file. I need to pass this file, as a >> regular file object, to a subprocess. Unfortunately, the 'mmap' >> module's file-like object doesn't appear to work quite like a regular >> file would. (I simply assume that mmap would be the way to go. Other >> suggestions welcome!) That, or I'm doing something terribly wrong. > > How about using a pipe for stdin? This seems to work: > > import sys > from subprocess import Popen, PIPE > > fishes = "one fish\ntwo fish\nred fish\nblue fish\n" > > proc1 = Popen(['cat'], stdin=PIPE, stdout=sys.stdout, stderr=sys.stderr) > proc1.stdin.write(fishes) > proc1.stdin.close() > > Kent > _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor