[Python-au] python library to discover file associations

Eric O'Donnell svvampy at gmail.com
Mon Feb 21 12:23:50 UTC 2011

Hi Mike,

If calling 'os.system(txtfile)' is not sufficient, in Windows you can trek
through the registry.

First HKEY_CLASSES_ROOT\.txt which points you to the 'txtfile' entry.
Then HKEY_CLASSES_ROOT\txtfile\shell\open\command
the value on my system is:
%SystemRoot%\system32\NOTEPAD.EXE %1

I don't know what you need to do on other platforms, perhaps look at the
code for os.system?

Hmm, I just tried that via Cygwin:
>>> import os
>>> os.name
>>> os.system('file.txt')
sh: file.txt: command not found

So maybe that's not as helpful as I thought.


On 21 February 2011 17:31, Mike Dewhirst <miked at dewhirst.com.au> wrote:

> I want to launch the system text editor with a known text file but I don't
> know what that editor might be on which platform.
> Is there a Python library which can discover the system text editor on any
> platform?
> Mike
> _______________________________________________
> python-au maillist  -  python-au at starship.python.net
> http://starship.python.net/mailman/listinfo/python-au
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://starship.python.net/pipermail/python-au/attachments/20110221/0fe70aa9/attachment.htm>

More information about the python-au mailing list