Message2752

Author cgroves
Recipients
Date 2007-07-27.06:37:53
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
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.
History
Date User Action Args
2008-02-20 17:18:44adminlinkissue1761139 messages
2008-02-20 17:18:44admincreate