read() on tempfile

Gerrit Holl gerrit at nl.linux.org
Thu Jan 29 15:57:38 EST 2004


cherico wrote:
> from tempfile import *
> 
> f = NamedTemporaryFile ()
> f = write ( 'test' )
> print f.read () #here print nothing

Strange, it should raise an Exception. 
I guess you typed it over?

'write' should give a NameError. You want to do f.write, not f=write.
After that, you first want to seek to 0.

Gerrit.

-- 
268. If any one hire an ox for threshing, the amount of the hire is
twenty ka of corn.
          -- 1780 BC, Hammurabi, Code of Law
-- 
PrePEP: Builtin path type
    http://people.nl.linux.org/~gerrit/creaties/path/pep-xxxx.html
Asperger's Syndrome - a personal approach:
	http://people.nl.linux.org/~gerrit/english/




More information about the Python-list mailing list