MC logo
Copy Input to Output IV
[^] Code Examples

# 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:
        s = input()
    except EOFError:

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.