File: class/Workbook/Examples/Lecture8/idioms.py
while 1:
try:
line = raw_input() # read from stdin
except EOFError:
break
else:
<process 'next' here>
###
Found = "Item found"
def searcher():
<raise Found or return>
try:
searcher()
except Found:
<success>
else:
<failure>
###
try:
<run program>
except: # all uncaught exceptions come here
import sys
print 'uncaught!', sys.exc_info()[0], sys.exc_info()[1]