Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > RE: tempfile.gettempdir() result on Windows

Reply
Thread Tools

RE: tempfile.gettempdir() result on Windows

 
 
Tim Golden
Guest
Posts: n/a
 
      06-03-2005
[Leo Breebaart]
|
| 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
| >>> tempfile.gettempdir()
| 'c:\\docume~1\\admini~1\\locals~1\\temp'
| >>>
|
| My problem (entirely cosmetic, but still) is that I also need to
| show this location to the users of my program, who I suspect
| would be much happier with a 'proper' Windows path than with this
| '~1' DOS malarkey.
|
| Does anybody know how I can obtain a temp directory in 'verbose'
| format (or somehow convert the gettempdir() result to that)?

Have a look at win32api.GetLongPathName
(from the pywin32 extensions, in case it wasn't
obvious). So something like this:

<code>
import tempfile
import win32api

print tempfile.gettempdir ()
print win32api.GetLongPathName (tempfile.gettempdir ())

</code>

TJG

__________________________________________________ ______________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
__________________________________________________ ______________________
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
i = 10; result = ++i - --i; How result become ZERO Lakshmi Sreekanth C Programming 52 09-23-2010 07:41 AM
Re: i = 10; result = ++i - --i; How result become ZERO Mr. Buffoon C Programming 4 09-23-2010 03:01 AM
Is the result of valid dynamic cast always equal to the result ofcorrespondent static cast? Pavel C++ 7 09-18-2010 11:35 PM
simulation result is correct but synthesis result is not correct J.Ram VHDL 7 12-03-2008 01:26 PM
1. Ruby result: 101 seconds , 2. Java result:9.8 seconds, 3. Perl result:62 seconds Michael Tan Ruby 32 07-21-2005 03:23 PM



Advertisments