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

Mark Lawrence breamoreboy at yahoo.co.uk
Thu Apr 12 10:27:56 EDT 2012


On 12/04/2012 08:00, Chris Angelico wrote:
> On Thu, Apr 12, 2012 at 4:02 PM, Karl Knechtel<zahlman at 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.




More information about the Python-list mailing list