tempfile behavior

billiejoex gnewsg3 at gmail.com
Thu Aug 9 15:47:10 EDT 2007


On 9 Ago, 20:31, half.ital... at gmail.com wrote:
> On Aug 9, 11:21 am, billiejoex <gnew... at gmail.com> wrote:
>
> > Hi all,
> > I would like to use tempfile module to generate files having unique
> > names excepting that I don't want them to be removed after closing.
> > Does it is possible?
>
> Looks like tempfile.mkstemp() will do what you want.
>
> '''Unlike TemporaryFile(), the user of mkstemp() is responsible for
> deleting the temporary file when done with it.'''
>
> ~Sean

Thank you, it seems good.
Just another question:

>>> fd, filename = tempfile.mkstemp()
>>> type(fd)
<type 'int'>

I would expect a file descriptor, not and integer.
How do I have to use it?




More information about the Python-list mailing list