Re: Understanding tempfile.TemporaryFile

2007-12-28 Thread Karthik Gurusamy
On Dec 27, 7:36 pm, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Thu, 27 Dec 2007 21:17:01 -0600, Shane Geiger wrote: > > import tempfile > > tmp = tempfile.mktemp() > > > import os > > os.remove(tmp) > > Not only does that not answer the Original Poster's question, but I don't > think it does w

Understanding tempfile.TemporaryFile

2007-12-27 Thread Brad
Wondering if someone would help me to better understand tempfile. I attempt to create a tempfile, write to it, read it, but it is not behaving as I expect. Any tips? >>> x = tempfile.TemporaryFile() >>> print x ', mode 'w+b' at 0xab364968> >>> print x.read() >>> print len(x.read()) 0 >>> x

Re: Understanding tempfile.TemporaryFile

2007-12-27 Thread Shane Geiger
Yes, I knew this. Good call, it was just a bad copy and paste example of lines that showed up close together in a file. My apologies. >> import tempfile >> tmp = tempfile.mktemp() >> >> import os >> os.remove(tmp) >> > > Not only does that not answer the Original Poster's question, but I do

Re: Understanding tempfile.TemporaryFile

2007-12-27 Thread Steven D'Aprano
On Thu, 27 Dec 2007 21:17:01 -0600, Shane Geiger wrote: > import tempfile > tmp = tempfile.mktemp() > > import os > os.remove(tmp) Not only does that not answer the Original Poster's question, but I don't think it does what you seem to think it does. >>> tmp = tempfile.mktemp() >>> tmp '/tmp/

Re: Understanding tempfile.TemporaryFile

2007-12-27 Thread byte8bits
On Dec 27, 10:12 pm, John Machin <[EMAIL PROTECTED]> wrote: > Check out the seek method. Ah yes... thank you: >>> import tempfile >>> x = tempfile.TemporaryFile() >>> x.write("test") >>> print x.read() >>> x.seek(0) >>> print x.read() test -- http://mail.python.org/mailman/listinfo/python-li

Re: Understanding tempfile.TemporaryFile

2007-12-27 Thread Steven D'Aprano
On Thu, 27 Dec 2007 18:49:06 -0800, byte8bits wrote: > Wondering if someone would help me to better understand tempfile. I > attempt to create a tempfile, write to it, read it, but it is not > behaving as I expect. Any tips? You need to seek to the part of the file you want to read: >>> x = temp

Re: Understanding tempfile.TemporaryFile

2007-12-27 Thread Shane Geiger
import tempfile tmp = tempfile.mktemp() import os os.remove(tmp) [EMAIL PROTECTED] wrote: > Wondering if someone would help me to better understand tempfile. I > attempt to create a tempfile, write to it, read it, but it is not > behaving as I expect. Any tips? > > x = tempfile.Temporar

Re: Understanding tempfile.TemporaryFile

2007-12-27 Thread John Machin
On Dec 28, 1:49 pm, [EMAIL PROTECTED] wrote: > Wondering if someone would help me to better understand tempfile. I > attempt to create a tempfile, write to it, read it, but it is not > behaving as I expect. Any tips? > > >>> x = tempfile.TemporaryFile() > >>> print x > > ', mode 'w+b' at 0xab364968

Understanding tempfile.TemporaryFile

2007-12-27 Thread byte8bits
Wondering if someone would help me to better understand tempfile. I attempt to create a tempfile, write to it, read it, but it is not behaving as I expect. Any tips? >>> x = tempfile.TemporaryFile() >>> print x ', mode 'w+b' at 0xab364968> >>> print x.read() >>> print len(x.read()) 0 >>> x.write(