[Achim Domma]
is there a way to tell windows, that *.py files are executable, like
.bat, .js, ...? If I have someTool.py somewhere in my path I would like
to type only 'someTool param1 param2'. Is that possible?
Not on a command.com system (95/98/ME). On a cmd.exe system
(NT/2K/XP), go to a DOS box and type
ftype /?
Skip down to the part explaining PATHEXT.
I'd forgotten where that was explained. Thanks. The OP might also
want to know that NT/2K/XP is not a guarantee of full satifaction,
(as you know ;-).
I.e., note that some versions (e.g. NT4.0) of windows don't do i/o redirection
properly for output generated by a script invoked via extension association.
IOW, e.g., someTool param1 param2 > result.txt may give you an empty result.txt.
Same for piping either input or output. This is not a python problem.
The same will happen for perl (and super-weird hacks have been attempted
to work around it IIRC ;-) So if you want to redicrect i/o on such
windows versions, you will have to run the scripts explicitly as arguments
to the python interpreter, e.g. python someTool.py param1 param2 > result.txt
and you will need to specify a full path to someTool.py if you are not in
the same directory. For stuff you use a lot, you will probably wind up writing
someTool.cmd (whose ouput will be redirectable) as a one-line invocation of
python and someTool.py (passing through all cmd line args). E.g.,
@python c:\pywk\ut\ppcomp2.py %*
starts a little utility for me, which I invoke as ppcomp -- which runs ppcomp.cmd
in c:\util -- which is on my session's path for the os's finding executables.
IIRC there's also a way to rename .py to .cmd and put a tricky first line in
to fake unix sort of and invoke python to interpret the rest as python, but
I'm repressing memory of the details ;-)
I guess newer windows versions don't have this problem so much, but it's worth
knowing, so you can recognize the symptom when it happens.
Regards,
Bengt Richter