raw stdin/out on WIN32?
Gordon McMillan
gmcm at hypernet.com
Wed Mar 15 20:49:04 EST 2000
Yann SAMAMA wrote:
> Finally I've found the solution to redefine the way stdin/out/err are opened
> on WIN32.
>
> ****code begins here****
> import sys
> if sys.platform == "win32":
> import msvcrt
> msvcrt.setmode(0, os.0_BINARY) # 0 = stdin, 1 = stdout, 2 = stderr, you
> can also use sys.stdin/out/err.fileno()
> ****code ends here****
>
> The most interesting thing is that this code raises an exception under
> PythonWin, and works perfectly when run from the shell (command.com)?
That's because Windows GUIs have no stdin, stdout or stderr.
Pythonwin emulates these, but they are not files at all.
- Gordon
More information about the Python-list
mailing list