Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   .py as executable extension on windows (http://www.velocityreviews.com/forums/t335845-py-as-executable-extension-on-windows.html)

Achim Domma (Procoders) 09-15-2004 08:30 PM

.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

JanC 09-15-2004 08:43 PM

Re: .py as executable extension on windows
 
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

Tim Peters 09-15-2004 08:45 PM

Re: .py as executable extension on windows
 
[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.

aurora 09-15-2004 08:54 PM

Re: .py as executable extension on windows
 
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)
<domma@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



Stefan Eischet 09-15-2004 09:30 PM

Re: .py as executable extension on windows
 
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)
> <domma@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
>
>



Bengt Richter 09-15-2004 10:04 PM

Re: .py as executable extension on windows
 
On Wed, 15 Sep 2004 16:45:41 -0400, Tim Peters <tim.peters@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


All times are GMT. The time now is 08:47 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57