yield i
vereq(list(tuple(f())), range(1000))
+# Verify that __getitem__ overrides are recognized by __iter__
+class T(tuple):
+ def __getitem__(self, key):
+ return str(key) + '!!!'
+vereq(iter(T()).next(), '0!!!')
+
print '6.5.3 Lists'
# calling built-in types without argument must return empty
if list() != []: raise TestFailed,'list() does not return []'
a[::2] = tuple(range(5))
vereq(a, [0, 1, 1, 3, 2, 5, 3, 7, 4, 9])
+# Verify that __getitem__ overrides are recognized by __iter__
+class L(list):
+ def __getitem__(self, key):
+ return str(key) + '!!!'
+vereq(iter(L()).next(), '0!!!')
+
print '6.6 Mappings == Dictionaries'
# calling built-in types without argument must return empty
PyErr_BadInternalCall();
return NULL;
}
+ if (seq->ob_type->tp_as_sequence->sq_item != list_item)
+ return PySeqIter_New(seq);
it = PyObject_GC_New(listiterobject, &PyListIter_Type);
if (it == NULL)
return NULL;
PyErr_BadInternalCall();
return NULL;
}
+ if (seq->ob_type->tp_as_sequence->sq_item != tupleitem)
+ return PySeqIter_New(seq);
it = PyObject_GC_New(tupleiterobject, &PyTupleIter_Type);
if (it == NULL)
return NULL;