471,092 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,092 software developers and data experts.

.py as executable extension on windows

Hi,

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?

regards,
Achim
Jul 18 '05 #1
5 1993
Achim Domma (Procoders) schreef:
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?


Google for "PATHEXT".

--
JanC

"Be strict when sending and tolerant when receiving."
RFC 1958 - Architectural Principles of the Internet - section 3.9
Jul 18 '05 #2
[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.
Jul 18 '05 #3
Some useful information in Windows faq

http://www.python.org/doc/faq/window...pts-executable
On Wed, 15 Sep 2004 22:30:33 +0200, Achim Domma (Procoders)
<do***@procoders.net> wrote:
Hi,

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?

regards,
Achim


Jul 18 '05 #4
Or try "sometool.py param1 param2"! Works fine for me.

Stefan

On 15.09.2004, at 22:54, aurora wrote:
Some useful information in Windows faq

http://www.python.org/doc/faq/window...i-make-python-
scripts-executable
On Wed, 15 Sep 2004 22:30:33 +0200, Achim Domma (Procoders)
<do***@procoders.net> wrote:
Hi,

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?

regards,
Achim


--
http://mail.python.org/mailman/listinfo/python-list


Jul 18 '05 #5
On Wed, 15 Sep 2004 16:45:41 -0400, Tim Peters <ti********@gmail.com> wrote:
[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
Jul 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

17 posts views Thread by Filipe Martins | last post: by
3 posts views Thread by Johnny | last post: by
2 posts views Thread by pooja | last post: by
28 posts views Thread by Tim Daneliuk | last post: by
16 posts views Thread by Erwin Moller | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.