Image

Imageguberif wrote in Imagepython_dev

windows: associating a file extension with a python script?

Does anyone know how to do this?

I've tried something very basic, my gut instinct shot, but it doesn't work. I'm digging through web searches now, but thought I'd post here too.



Here's the basic one:

file "association_test.py":

import sys

f = file("c:\\tmp\\association.txt", "w+")
f.writelines(sys.argv)
f.close()


Then I created a file, "test.xyz" double clicked on it, and told windows that it should associate it with association_test.py.

When I hit OK I get: C:\path\test.xyz is not a valid Win32 application.

It doesn't say "association_test.py" isn't valid, but my test file.

The association_test.py script runs fine by itself, and puts "association_test.py" in the file(because that's argv[0]).

It seems most likely that my assumption that argv would contain the associated filename is not correct, but hey, I don't know for sure. I'll keep looking online, of course.

I'm running XP Pro SP2 all patched up to current, and Python 2.4.3.