subprocess.Popen() OS compatibility

Hello
I’m working on a python script for a game (game content is not relevant here), but under a certain condition I need the script to open a folder in the form of the OS’s explorer window.


import subprocess
subprocess.Popen('explorer "'+l.expandPath('//saves')+'"')
# ex: Popen('explorer "C:\Users\Name\Desktop\saves\"')

I’m opening the /saves/ folder where the .blend is stored. I found this code on a website that mentioned it was for Windows, but didn’t say anything about compatibility with other operating systems. The code works fine for me (using Windows).

So I’m just curious, will this code work on other operating systems and properly open the specific directory in its explorer window? If it doesn’t, is there any other code anyone could suggest I use to open a folder path?

I’m running xfce and this opens a default file browser


exo-open --launch FileManager

And this will help find the processes user home directory:
http://snipplr.com/view/7354/get-home-directory-path--in-python-win-lin-other/
and here’s some accompanying notes for ‘expanduser’:
http://docs.python.org/library/os.path.html

It works fine in Linux. I can’t remember whether it works in Mac or not (could someone confirm?)