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

Tim Roberts timr at probo.com
Mon Nov 17 20:09:45 CET 2008


Tim Roberts wrote:
> 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.

I realized when I read my reply that I really did nothing to clear up
any confusion.  Allow me to provide an example.

Let's say I have c:\bin\remote.py, and client.py in the current
directory.  WIthout the file associations for .py and .pyw, I can say:
    python client.py
    pythonw client.py
If I set up file associations for .py and .py, then I can also say:
    client.py
    .\client.py
Further, as long as "c:\bin" is in the path, I can also say:
    remote.py

When I add .PY and .PYW to PATHEXT, that also lets me say:
    client
    remote

without the extension.  That's the sole purpose for PATHEXT.

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



More information about the python-win32 mailing list