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
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
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
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/
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
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
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
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
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(