Here are some commands you can use (tested on WinXP, so YMMV):
1. The os.system function
import os
os.system('explorer "c:\program files"')
This has the disadvantage that a cmd.exe windows is also opened,
because os.system executes the command in a subshell.
But using this approach the explorer starts in front of all other windows.
2. The os.startfile function
import os
os.startfile("C:\program files")
Using startfile doesn't open a cmd.exe window, but the folder window
is not started in front of the other windows
3. The subprocess.Popen function
import subprocess
subprocess.Popen('explorer "C:\program files"')
With subprocess.Popen no cmd.exe window is opened and the explorer
starts in front of the other windows.
But the subprocess module is new in Python 2.4.
Bye,
Dennis
Maybe this is good enough?
os.system("explorer " + folder_path)
/ug
There are two issues here. The first is how to open a folder and the
second is how to resolve "special" folders. Folders are "documents"
typically associated with the explorer.exe application. To open a
document with its default app (e.g., a folder), use os.startfile which
is included in Python. For example:
import os
os.startfile(r'c:\windows')
Folders like My Documents, My Pictures, etc. are special and you need to
determine their actual path before you can open them. The pywin32
extensions
(https://sourceforge.net/project/showfiles.php?group_id=78018) include a
way to get at this:
from win32com.shell import shellcon, shell
path = shell.SHGetFolderPath(0, shellcon.CSIDL_MYPICTURES, 0, 0)
os.startfile(path)
Google for CSIDL to find the constants to use for other special folders.
Jimmy
Here's the exact link you'll need (warning, long url ahead ;)
--
Vincent Wehren
>
> Jimmy
os.system("start .")
works for me.
regards
Steve
--
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/
Holden Web LLC +1 703 861 4237 +1 800 494 3119