Bill McClain wrote:
On 2008-10-31, Glenn Linderman <[EMAIL PROTECTED]> wrote:

The problem with stdin/stdout is on Windows 2000 (and maybe the earlier NT?). But not on XP or AFAIK Vista.

It only occurs when a program is executed indirectly using the file associations instead of directly via the command line.

File associations, are the Windows "let's do it a different way" alternative for Unix she-bang lines (#!/path/to/python).

Can you elaborate on this? I have some very simple command-line utilities I
would like to make available on different platforms, but what little I knew
about Windows is fading into the past.

This example:

    import sys
    print sys.stdin.read()

...works in the Windows XP dos box if I do:

    python demo.py < file.txt

...but I get the error 9 for:

    demo.py < file.txt

Is there any way to make the second version work on Windows?

You've got a few options. Perhaps the simplest is to use something
like the effbots exemaker [1] which creates a stub for your script
but which is an .exe to the redirection should work. The user has
to have Python installed on the system (it's not a py2exe lookalike)
but it can make things like this simpler.

I believe -- but I've never really gone into this -- that the
setuptools extensions to distutils offer a way to do this as
part of the installation, so if you were having the scripts
installed via a setup.py (or setup.whetever) then that might
be the way.

Obviously py2exe (also a distutils extension) is another
possibility, altho' I would see it here as a fallback option
since it's a bit more heavyweight.

This is the MS article which describes the problem:

 http://support.microsoft.com/kb/321788

and suggests that it's fixed in XP SP1 but this
thread:

 http://mail.python.org/pipermail/python-list/2008-September/506466.html

suggests that maybe it's not.

TJG
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to