473,387 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 2072
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: QQ June | last post by:
Hello, I have some java classes. But, I don't want my users to type "java my_java_program" every time they run the java class ? How do I pack them together into one executable file, like...
17
by: Filipe Martins | last post by:
Hello. I've read somewhere that the executable is smaller if we use a source file for each function! So, I tested this with gcc and it seams to confirm! What seams to happen is that if we call...
3
by: Johnny | last post by:
How do I create a link on a Web page on my hard drive that will run an executable file on my hard drive? For example, let's say I create runpoodle.htm and save it to my hard drive, and let's...
3
by: Gustavo L. Fabro | last post by:
Greetings! I'm testing VS 2005 Beta 2, and I've compiled a program that runs just fine on my computer (where VS is installed). I've tried to run this same program on another computer (after...
8
by: suresh_C# | last post by:
Dear All, What is difference between Portable Executable (PE) file and a Assembly? Thanks, Mahesh
2
by: pooja | last post by:
what is an assembly and how does it related with portable executable in ..net architecture?
28
by: Tim Daneliuk | last post by:
I have a program wherein I want one behavior when a file is set as executable and a different behavior if it is not. Is there a simple way to determine whether a given named file is executable...
16
by: Erwin Moller | last post by:
Why is a binary file executable? Is any binary file executable? Is only binary file executable? Are all executable files binary? What is the connection between the attribute of binary and that of...
1
by: KMEscherich | last post by:
Hi there, am totally new at creating an executable for a PDF file. I have created a PDF file and placed it on a CD. Now, I want to be able to have this PDF file automatically open up in any...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.