reading a text file
Tino Wildenhain
tino at wildenhain.de
Wed Aug 19 07:09:28 EDT 2009
superpollo wrote:
> hi clp
>
> what's the difference between:
>
> while True:
> input_line = sys.stdin.readline()
> if input_line:
> sys.stdout.write(input_line.upper())
> else:
> break
>
> and:
>
>
> while True:
> try:
> sys.stdout.write(sys.stdin.next().upper())
> except StopIteration:
> break
>
More useless code, under the hood its working similar.
But why not use it in the way intended?
for input_line in sys.stdin:
sys.stdout.write(input_line.upper())
?
Regards
Tino
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3241 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20090819/c0bc96da/attachment-0001.bin>
More information about the Python-list
mailing list