eof.py 465 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#!   /user/dcobas/2.7.1/bin/python
#    coding: utf8

import sys

if __name__ == '__main__':
    input = sys.stdin
    x = raw_input('Dime algo')
    print 'x = [{0}]'.format(x)
    try:
        sys.stdin = file('/dev/null')
        x = raw_input('Dime algo')
        print 'x = [{0}]'.format(x)
    except EOFError:
        print 'found EOF when reading from redirected stdin'
    sys.stdin = input
    x = raw_input('Dime algo')
    print 'x = [{0}]'.format(x)