reading a text file

Paul Rubin http
Wed Aug 19 04:46:16 EDT 2009


superpollo <user at example.net> writes:
> while True:
>      try:
>          sys.stdout.write(sys.stdin.next().upper())
>      except StopIteration:
>          break

Maybe there is some subtle difference, but it looks like you really mean

   for line in sys.stdin:
       sys.stdout.write(line.upper())



More information about the Python-list mailing list