[python-win32] How to make python scripts output to current cmd window? (like linux terminal)

Tim Roberts timr at probo.com
Mon Nov 17 19:50:03 CET 2008


sayeo87 wrote:
> Right now on Windows I have added ".py" to my PATHEXT so that I can run .py
> files by doing ./<filename>.py. But when I do this the output of the program
> goes to a new command prompt window which instantly disappears. How can I
> instead make the output go to the current command prompt window I'm working
> in, like in a linux terminal?
>
> Sorry if this has been answered before but I've googled high and low and
> still can't seem to find how to do this.
>   

What PATHEXT lets you do is run the command without specifying a path at
all.  As long as the file is in the same directory, the file association
will work.  PATHEXT allows you to put Python scripts in your c:\bin
directory, for example, and then use them without specifying the path or
the extension.  So, I have a Python version of "which" that I store in
my \bin directory under the name "which.py".  But from a command line,
all I have to type is "which".

I'm surprised by your description.  Check your file associations.  From
your command line, say
    assoc .py
On my machine, it says:
    .py=Python.File

Then, check the ftype:
    ftype Python.File
On my machine, it says:
    python.file="C:\Apps\Python24\Python.exe" "%1" "%*

I see that you wrote "./<filename>.py".  Was that an accident, or are
you using a shell other than "cmd"?

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list