Lichen

tests/list.py

272:bfcff34674bb
2016-11-28 Paul Boddie Show the types of unhandled exceptions.
     1 l = [1, 2, 3]     2 l.append("four")     3 print len(l)            # 3     4 print l[0]              # 1     5 print l[1]              # 2     6 print l[2]              # 3     7 print l[3]              # four     8 print l[-1]             # four     9 print l[-2]             # 3    10 print l[-3]             # 2    11 print l[-4]             # 1    12 print l                 # [1, 2, 3, "four"]    13     14 t = (1, 2, 3, "four")    15 l = list(t)    16 print l                 # [1, 2, 3, "four"]    17     18 try:    19     print l[4]          # should raise an exception    20 except IndexError, exc:    21     print "l[4]: failed with argument", exc.index    22     23 try:    24     print l[-5]         # should raise an exception    25 except IndexError, exc:    26     print "l[-5]: failed with argument", exc.index