OS independent file associate ?

Stef Mientki stef.mientki at gmail.com
Thu May 14 15:20:07 EDT 2009


I would like to make my programs available under the "standard" OS's, 
like Windows, Linux  (,Mac)
One of the problems I encounter, is launching of files through their 
file associates (probably a windows only terminology ;-)
Now I can detect the OS, but only the main OS and not e.g. Ubuntu / 
Gnome or whatever I've to detect.
Through trial and error I found a working mechanism under Ubuntu, but as 
I have to specify "gnome", I doubt this will work under other Linux systems.

any good solutions available ?

Stef Mientki

    import subprocess
    CHM = '../numpy.chm'
    # works under Ubuntu
    subprocess.Popen( "gnome-open " + CHM , shell = True )

    # doesn't work under Ubuntu
    # (the list should be converted to a number of arguments,
    #but that doesn't seem to work under Ubuntu.
    subprocess.Popen( [ "gnome-open" , CHM] ,shell = True )

    # works under Windows
    subprocess.Popen( CHM , shell = True )

    # works better under windows
    win32help.HtmlHelp ( Win32_Viewer,
                         str ( keyword ) )


More information about the Python-list mailing list