[Tutor] tempfile and webbrowser
yves
yegrix at free.fr
Sun Sep 3 19:23:23 CEST 2006
Hello tutors,
This programm works:
**********
import webbrowser
a = open('test.htm','wb')
a.write("<html>Test</html>")
webbrowser.open(a.name)
a.close()
***********
but I would like to avoid the risk of overwriting an already existing
"test.htm" file, so I try to use the module tempfile:
***********
import tempfile
import webbrowser
a = tempfile.NamedTemporaryFile('w+b',-1,'.html')
a.write("<html>Test</html>")
webbrowser.open(a.name)
#a.close()
**********
This does not work (no traceback error though): the browser displays a
blank page.
I am using Python2.3.3 on Windows XP, and Firefox.
Have you got some suggestions to tackle this problem?
--
Yves Egrix
More information about the Tutor
mailing list