469,592 Members | 1,674 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,592 developers. It's quick & easy.

tempfile behavior

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
4 1016
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
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
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
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.

Similar topics

3 posts views Thread by Thomas Guettler | last post: by
2 posts views Thread by marco | last post: by
1 post views Thread by Matt Garman | last post: by
reply views Thread by Leo Breebaart | last post: by
reply views Thread by Colin Wildsmith | last post: by
6 posts views Thread by James T. Dennis | last post: by
9 posts views Thread by billiejoex | last post: by
7 posts views Thread by byte8bits | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.