472,110 Members | 2,118 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,110 software developers and data experts.

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 1071
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 leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.