Cannot redirect output when I run Python script on Windows using just script's name
Are you asking about this?
Windows: When executing Python scripts on the command line using file type associations (i.e. starting "script.py" instead of "python script.py"), redirects may not work unless you set a specific registry key. See the Knowledge Base article STDIN/STDOUT Redirection May Not Work If Started from a File Association.
It's in the Python README. Perhaps this patch is what you're looking for.
UPDATED ANSWER
A Microsoft KB issue (STDIN/STDOUT Redirection May Not Work If Started from a File Association) may be exactly this issue. The page has instructions for downloading a Win2000 hotfix, but that might not be needed on more recent Windows versions. After the hotfix (or possibly without it, depending on your Win version), a manual registry edit is needed.
You should check the link I provided; in any case, I summarize here:
- Open Registry Editor and locate the key
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
- Add a DWORD value named
InheritConsoleHandles
and set it to1
.
That's it, supposedly.
If you are trying to redirect stdout and stderr from the command prompt,see http://support.microsoft.com/kb/110930