[Tutor] Shebang (#!) in the first line of a python script

Dave Angel davea at ieee.org
Wed Oct 14 03:31:57 CEST 2009


Scott Markwell wrote:
> On Tue, Oct 13, 2009 at 1:54 PM, Dave Angel <davea at ieee.org> wrote:
>
>   
>> Katt wrote:
>>
>>     
>>> <snip>
>>> You were right.  I did not have .PY/.PYW in my PATHEXT.  I have put it in
>>> as
>>> suggested.  I do have python.exe in my path so that should take care of
>>> things.
>>>
>>> Messing around with the windows registry isn't something I want to tackle
>>> just yet so I will save that for later.
>>>
>>> Thank you for your help,
>>>
>>> Katt
>>>
>>>       
>> You don't have to directly mess with the registry.  But if you just enter
>> the script name, you are causing the registry lookups just the same.  As I
>> said, the install took care of it for you, and you shouldn't have to change
>> till you have two installs.
>>
>> But to re-iterate:  When you run a script this way, the PATH is *not* used
>> to look up the Python.exe, but only to search for the script.
>>
>> DaveA
>>
>>
>>     
> You can do it strictly through the explorer. Right click on any .py or .pyw
> file and select 'properties.' Where it says 'open with' click 'change.' In
> the dialog select 'other' and browse to python.exe. Make sure it's the
> python.exe from the version you want to use.
>
> I just installed python 2.6 and had to do that and set the paths manually as
> for some reason the installer didn't do it for me.
>
> (oops hit "reply" the first time instead of "reply all." New to this mailing
> list thing.)
>
>   
>> _
Presumably the reason your python upgrade didn't change them is you told 
the installer that you didn't want it to be the default installation.  
As you say, you can fix that in Explorer.  But you can also use 
assoc.exe and ftype.exe

The reason I prefer assoc and ftype is that they're command line 
utilities that fix the associations.  Thus simple batch files of pythons 
scripts can switch things back and forth once you need the extra 
flexibility.

DaveA



More information about the Tutor mailing list