473,320 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 1116
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Pierre Rouleau | last post by:
Hi all! I am using Python 2.3.1 on Win32 (NT, 2000). Whenever a file imports the standard tempfile module, Python 2.3.1 issues the following warning: C:\Python23\lib\fcntl.py:7:...
3
by: Thomas Guettler | last post by:
Hi! Is there a need for the "@" in the filenames created with tempfile.mktemp()? I think it would be better to use only characters which are "shell save". At least with bash you need to...
2
by: marco | last post by:
Hello, I having a problem creating directories with Python 2.3.4 (compiled with gcc 3.2.2, under Linux 2.4.20-31.9). I'm writing a plugin which works in the following way: GUI --...
1
by: Matt Garman | last post by:
I've been working on a curses-based application in Python. My application effectively has a series of screens (or windows). When one screen closes, the previous screen should be exactly redrawin...
0
by: Leo Breebaart | last post by:
On MS Windows, I am trying to find out a good default location to save some temporary files. The tempfile module seemed to have exactly what I wanted: >>> import tempfile >>>...
0
by: Colin Wildsmith | last post by:
Hello, I am trying to create a temp file, however the file that is created is still there after the program has completed. Why is this so? CoLe #!/usr/bin/python import os, tempfile, sys
6
by: James T. Dennis | last post by:
Tonight I discovered something odd in the __doc__ for tempfile as shipped with Python 2.4.4 and 2.5: it says: This module also provides some data items to the user: TMP_MAX - maximum number...
9
by: billiejoex | last post by:
Hi there. I'm trying to generate a brand new file with a unique name by using tempfile.mkstemp(). In conjunction I used os.fdopen() to get a wrapper around file properties (write & read methods,...
7
by: byte8bits | last post by:
Wondering if someone would help me to better understand tempfile. I attempt to create a tempfile, write to it, read it, but it is not behaving as I expect. Any tips? <open file '<fdopen>', mode...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.