Message2752
Right, that's the same thing I was reading in the pep. It's saying it should work on anything that has __getitem__ and __len__ which doesn't correspond to PySequence in Jython. PySequence is just the baseclass for builtin sequence types like PyList and PyTuple. Any PyObject can implement those methods.
PySequence_Check in CPython is the following:
int
PySequence_Check(PyObject *s)
{
if (s && PyInstance_Check(s))
return PyObject_HasAttrString(s, "__getitem__");
if (PyObject_IsInstance(s, (PyObject *)&PyDict_Type))
return 0;
return s != NULL && s->ob_type->tp_as_sequence &&
s->ob_type->tp_as_sequence->sq_item != NULL;
}
Essentially it returns true if the object is an instance of a user-defined class with a __getitem__ attribute, or if it isn't a subclass of dict and it is a builtin sequence type. |
|
Date |
User |
Action |
Args |
2008-02-20 17:18:44 | admin | link | issue1761139 messages |
2008-02-20 17:18:44 | admin | create | |
|