Using command line args on Windows

Tim Roberts timr at probo.com
Sun Oct 9 04:25:04 EDT 2005


Duncan Booth <duncan.booth at invalid.invalid> wrote:

>Fredrik Lundh wrote:
>
>> footnote: if you'd prefer to type "myscript myarg" instead, you might
>> want to check out this tool:
>> 
>>     http://effbot.org/zone/exemaker.htm
>
>or even just do:
>
>    SET PATHEXT=.py;%PATHEXT%
>
>and then "myscript myarg" will work for all scripts on your path without 
>compiling (if you don't set PATHEXT then "myscript.py myarg" will still 
>work, and tab completion means you don't generally need to type the .py for 
>scripts in the current directory). 

The downside to this is that there is a bug in the NT/2K/XP command
interpreter which will prevent redirecting from stdin in that case.  That
is:

C:\Tmp>type x.py
import sys
print sys.stdin.readline()

C:\Tmp>echo 123 | python x.py
123

C:\Tmp>echo 123 | x.py
The process tried to write to a nonexistent pipe.

C:\Tmp>python x.py < x.py
import sys

C:\Tmp>x.py < x.py

C:\Tmp>
-- 
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list