Copy Input to Output IV
#!/usr/bin/python3
# Script to copy standard input to standard output using the
# basic raw input function.
#
# Here's an example: Copy standard input to standard output.
while 1:
try:
s = input()
except EOFError:
break
print(s)
Like Java, python uses exceptions
to deal with EOF and other I/O conditions.
This is a very flexible and powerful model.
Fortunately, Python also provides I/O primitives that
don't require the programmer to use exceptions (though
these facilities presumably are implemented using them).
Exceptions are very powerful, but
when you need to trim twigs, you
really don't want a chainsaw.