| 65 | } |
| 66 | |
| 67 | void exercise(list x, object y, object print) |
| 68 | { |
| 69 | x.append(y); |
| 70 | x.append(5); |
| 71 | x.append(X(3)); |
| 72 | |
| 73 | print("after append:"); |
| 74 | print(x); |
| 75 | |
| 76 | print("number of", y, "instances:", x.count(y)); |
| 77 | |
| 78 | print("number of 5s:", x.count(5)); |
| 79 | |
| 80 | x.extend("xyz"); |
| 81 | print("after extend:"); |
| 82 | print(x); |
| 83 | print("index of", y, "is:", x.index(y)); |
| 84 | print("index of 'l' is:", x.index("l")); |
| 85 | |
| 86 | x.insert(4, 666); |
| 87 | print("after inserting 666:"); |
| 88 | print(x); |
| 89 | print("inserting with object as index:"); |
| 90 | x.insert(x[x.index(5)], "---"); |
| 91 | print(x); |
| 92 | |
| 93 | print("popping..."); |
| 94 | x.pop(); |
| 95 | print(x); |
| 96 | x.pop(x[x.index(5)]); |
| 97 | print(x); |
| 98 | x.pop(x.index(5)); |
| 99 | print(x); |
| 100 | |
| 101 | print("removing", y); |
| 102 | x.remove(y); |
| 103 | print(x); |
| 104 | print("removing", 666); |
| 105 | x.remove(666); |
| 106 | print(x); |
| 107 | |
| 108 | print("reversing..."); |
| 109 | x.reverse(); |
| 110 | print(x); |
| 111 | |
| 112 | print("sorted:"); |
| 113 | x.pop(2); // make sorting predictable |
| 114 | x.pop(2); // remove [1,2] so the list is sortable in py3k |
| 115 | x.sort(); |
| 116 | print(x); |
| 117 | |
| 118 | print("reverse sorted:"); |
| 119 | #if PY_VERSION_HEX >= 0x03000000 |
| 120 | x.sort(*tuple(), **dict(make_tuple(make_tuple("reverse", true)))); |
| 121 | #else |
| 122 | x.sort(¬cmp); |
| 123 | #endif |
| 124 | print(x); |
nothing calls this directly
no test coverage detected