How to get a file object from mkstemp()?

Viewed 6879

I'm trying to use mkstemp with Python 3:

Python 3.2.3 (default, Jun 25 2012, 23:10:56) 
[GCC 4.7.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from tempfile import mkstemp
>>> mkstemp()
(3, '/tmp/tmp080316')

According to the documentation, the first element of the tuple is supposed to be a file handle. In fact, it's an int. How do I get a proper file object?

3 Answers
Related