How to get a file object from mkstemp()?
file, python
Solution
In the documentation for `mktemp` you can see an example of how to use `NamedTemporaryFile` the way you want: http://docs.python.org/dev/library/tempfile.html?highlight=mkstemp#tempfile.mktemp
>>> f = NamedTemporaryFile(delete=False)
>>> f
<open file '<fdopen>', mode 'w+b' at 0x384698>
This provides the same behavior as mkstemp, but returns a file object.
Problem
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?