[Windows] drag-and-drop onto .py file in modern versions?

Karl Knechtel zahlman at gmail.com
Thu Apr 12 02:02:04 EDT 2012


Hello all,

Back when I had 2.6.x installed, I used to be able to drag a file onto a
.py file in order to open it with that script (rather, pass the name of the
file as `sys.argv[1]`). I did nothing special to make this work, as far as
I can recall; it was something that the installer set up automatically. I
am running Windows Vista.

Now that I have uninstalled 2.6.x, and have 2.7.2 and 3.2.2 installed, this
behaviour no longer works. The .py file is apparently not recognized by
Vista as a valid drop target; it does not highlight, and when I release the
mouse, the dragged file is simply moved to / reordered within the
containing folder.

I was able to find a registry hack that is supposed to re-enable this
behaviour:

http://mindlesstechnology.wordpress.com/2008/03/29/make-python-scripts-droppable-in-windows/

However, I tried this and it had no effect whatsoever.

Is there any way I can get the drag-and-drop behaviour back? Was it
deliberately disabled for some reason? It was exceptionally convenient for
several of my scripts, and now I have to make .bat wrappers for each one to
get the same convenience.

Aside: when I double-click a .py file, what determines which Python will
run it? Is it a matter of which appears first in the PATH, or do I have to
set something else in the registry? Will a shebang line override the
default on Windows? If so, how do I write a shebang line for a Windows path
- just "#!C:/Windows/Python32"?

-- 
~Zahlman {:>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120412/ada9af6f/attachment.html>


More information about the Python-list mailing list