read() on tempfile

Sidharth Kuruvila sidharthk at hotmail.com
Thu Jan 29 13:59:35 EST 2004


"cherico" <cherico at bonbon.net> wrote in message
news:afc115ec.0401291041.155b51ee at posting.google.com...
> from tempfile import *
>
> f = NamedTemporaryFile ()
> f = write ( 'test' )
> print f.read () #here print nothing
>
> why is it nothing to read()?
> I suppose f is of mode 'w+'

the rpoblem is probably that your file pointer is sitting at the end of the
file after you write something
try f.seek(0) before you read, might work






More information about the Python-list mailing list