By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,035 Members | 1,388 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,035 IT Pros & Developers. It's quick & easy.

tempfile behavior

P: n/a
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?

Aug 9 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Aug 9, 11:21 am, billiejoex <gnew...@gmail.comwrote:
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

Aug 9 '07 #2

P: n/a
On 9 Ago, 20:31, half.ital...@gmail.com wrote:
On Aug 9, 11:21 am, billiejoex <gnew...@gmail.comwrote:
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?

Aug 9 '07 #3

P: n/a
On Thu, 09 Aug 2007 12:47:10 -0700, billiejoex wrote:
>>>fd, filename = tempfile.mkstemp()
type(fd)
<type 'int'>

I would expect a file descriptor, not and integer.
How do I have to use it?
File descriptors are integers. It's a low level C thing. Either use the
low level functions in `os` or open the file with the `filename`.

Ciao,
Marc 'BlackJack' Rintsch
Aug 9 '07 #4

P: n/a
Marc 'BlackJack' Rintsch wrote:
File descriptors are integers. It's a low level C thing. Either use the
low level functions in `os` or open the file with the `filename`.
In particular, os.fdopen(fd) will give you a
file object.

--
Greg
Aug 10 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.