[Windows] drag-and-drop onto .py file in modern versions?
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 {: -- http://mail.python.org/mailman/listinfo/python-list
Re: [Windows] drag-and-drop onto .py file in modern versions?
On Thu, Apr 12, 2012 at 4:02 PM, Karl Knechtel zahl...@gmail.com wrote: 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? Apologies - I can't answer your main question, and am just picking up the aside. The file-type association (which is really a file-extension association) determines the path to the executable. If that's specified without a full path, then it'll be the first one in PATH, but usually the association is given as an absolute filespec. I don't have a Vista handy, but in XP, bring up any folder, Options|Folder Options, File Types, and scroll down to PY. (For some obscure reason, on this particular computer of mine the association is with a Python that was installed with GNU Lilypond. Weird!) You may need to use the Advanced button to see the full path. As to writing a shebang, there's no way to do that directly. But in theory you could associate .py files with a little script that reads the first line and figures out which interpreter to invoke it in. For extra coolness points, write that script in portable Python that can be run on any of the interpreters you have installed - then you don't have to care! :) Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Re: [Windows] drag-and-drop onto .py file in modern versions?
On 12/04/2012 08:00, Chris Angelico wrote: On Thu, Apr 12, 2012 at 4:02 PM, Karl Knechtelzahl...@gmail.com wrote: 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? Apologies - I can't answer your main question, and am just picking up the aside. The file-type association (which is really a file-extension association) determines the path to the executable. If that's specified without a full path, then it'll be the first one in PATH, but usually the association is given as an absolute filespec. I don't have a Vista handy, but in XP, bring up any folder, Options|Folder Options, File Types, and scroll down to PY. (For some obscure reason, on this particular computer of mine the association is with a Python that was installed with GNU Lilypond. Weird!) You may need to use the Advanced button to see the full path. As to writing a shebang, there's no way to do that directly. But in theory you could associate .py files with a little script that reads the first line and figures out which interpreter to invoke it in. For extra coolness points, write that script in portable Python that can be run on any of the interpreters you have installed - then you don't have to care! :) Chris Angelico For the record please see http://www.python.org/dev/peps/pep-0397/ Python launcher for Windows which discusses shebang lines. -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list