LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-22-2006, 06:27 PM   #1
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Rep: Reputation: 45
Python help: proper use of testfile.NamedTemporaryFile()


Hello all,

I Need to figure out how to call testfile.NamedTemporaryFile() so I can use a specific file name instead of the randomly generated one.

I have 0 experience in python and I was attempting to modify the source of a python app (gmailfs.py: see section 4.2 on: showthread.php?t=447218 for more info) to get it to do what I want. I do have experience in C/C++ so I was able to figure out what was going on (sort of) be reading the code. It looks like the code creates a randomly named file to contain some saved data. I need to create the new file with the same name as the old one.

I found that NamedTemporaryFile() is a function in tempfile.py so I tried having gmailfs.py call the function as so:
Code:
tmpf = tempfile.NamedTemporaryFile('w+b',-1,"",name,None)
where name is the name of the old file, and all other parameters are the defaults listed in testfile.py. It will create the file with 'name' as the prefix and the random garbage tacked onto the end. Passing a suffix parameter just added the suffix to the end of the random garbage.

Is there an easy way to call this function with a specifically named file with no randomness in the name?

Thanks everybody for your time!
...drkstr

**edit**
I realize I also mention this question in the thread listed above, however I thought it better to have it's own thread.
sorry to double post!
...drkstr
**edit**

Last edited by drkstr; 05-22-2006 at 06:42 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Processing Conflict: python-devel conflicts python< 2.3.4-13.1 guarriman Fedora 2 04-23-2009 07:02 PM
python problem - compiled from source - python -V still showing old version txm123 Linux - Newbie 1 02-15-2006 11:05 AM
installing python library's (Python Numeric) Four Linux - Newbie 1 10-16-2005 02:31 PM
What means: ...proper Python link flags? BroX Linux - Software 5 04-21-2004 09:40 PM
install python 2.3 ,necssary to remove python 2.2 ngan_yine Linux - Newbie 7 12-28-2003 04:07 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration