stdin / stdout doubts..
Alessio Pace
puccio_13 at yahoo.it
Fri May 2 15:18:07 EDT 2003
Donn Cave wrote:
> Quoth Alessio Pace <puccio_13 at yahoo.it>:
> | Hi, I have some doubts about the way I deal with stdin and stdout.
> | I do:
> | import sys
> |
> | multi_line_text = sys.stdin.read()
> | # do something on the text
> | # ...
> | sys.stdout.write(modified_multi_line_text)
> |
> | Is this the preferable way? Or is there another way to make Python read
> | from stdin/write to stdout
>
> It's the right way as a general rule.
>
> You could probably make the "print" statement work for output, but it
> doesn't look like it would suit your application as well. In some
> exotic situations, on certain platforms (UNIX) you might have reasons
> to use the posix read and write functions, for example if you have been
> using select() to determine if data is available for input.
>
> Donn Cave, donn at u.washington.edu
Thank you guys.
--
bye
Alessio Pace
More information about the Python-list
mailing list