Lichen

tests/list.py

336:8c75cdf1a764
2016-12-06 Paul Boddie Introduced stream classes employing C-level FILE pointers, changing the sys stdin, stdout and stderr objects to be instances of these stream classes. Added fread and fwrite support to the native functions. Added support for raising EOFError.
     1 l = [1, 2, 3]     2 l.append("four")     3 print len(l)            # 4     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    27     28 print 1 in l            # True    29 print 4 in l            # False    30 print "four" in l       # True    31 print "one" in l        # False    32 print 1 not in l        # False    33 print 4 not in l        # True    34 print "four" not in l   # False    35 print "one" not in l    # True    36     37 print l.index(1)        # 0    38 print l.index("four")   # 3    39     40 try:    41     print l.index(4)    # should raise an exception    42 except ValueError, exc:    43     print "l.index(4): failed to find argument", exc.value