GNU Info

Info Node: (python2.1-api.info)Sequence Protocol

(python2.1-api.info)Sequence Protocol


Next: Mapping Protocol Prev: Number Protocol Up: Abstract Objects Layer
Enter node , (file) or (file)node

Sequence Protocol
=================

`int PySequence_Check(PyObject *o)'
     Return `1' if the object provides sequence protocol, and `0'
     otherwise.  This function always succeeds.

`int PySequence_Size(PyObject *o)'
     Returns the number of objects in sequence O on success, and `-1'
     on failure.  For objects that do not provide sequence protocol,
     this is equivalent to the Python expression `len(O)'.

`int PySequence_Length(PyObject *o)'
     Alternate name for `PySequence_Size()'.

`PyObject* PySequence_Concat(PyObject *o1, PyObject *o2)'
     Return the concatenation of O1 and O2 on success, and `NULL' on
     failure.   This is the equivalent of the Python expression `O1 +
     O2'.

`PyObject* PySequence_Repeat(PyObject *o, int count)'
     Return the result of repeating sequence object O COUNT times, or
     `NULL' on failure.  This is the equivalent of the Python
     expression `O * COUNT'.

`PyObject* PySequence_InPlaceConcat(PyObject *o1, PyObject *o2)'
     Return the concatenation of O1 and O2 on success, and `NULL' on
     failure.  The operation is done _in-place_ when O1 supports it.
     This is the equivalent of the Python expression `O1 += O2'.

`PyObject* PySequence_InPlaceRepeat(PyObject *o, int count)'
     Return the result of repeating sequence object O COUNT times, or
     `NULL' on failure.  The operation is done _in-place_ when O
     supports it.  This is the equivalent of the Python expression `O
     *= COUNT'.

`PyObject* PySequence_GetItem(PyObject *o, int i)'
     Return the Ith element of O, or `NULL' on failure. This is the
     equivalent of the Python expression `O[I]'.

`PyObject* PySequence_GetSlice(PyObject *o, int i1, int i2)'
     Return the slice of sequence object O between I1 and I2, or `NULL'
     on failure. This is the equivalent of the Python expression
     `O[I1:I2]'.

`int PySequence_SetItem(PyObject *o, int i, PyObject *v)'
     Assign object V to the Ith element of O.  Returns `-1' on failure.
     This is the equivalent of the Python statement `O[I] = V'.

`int PySequence_DelItem(PyObject *o, int i)'
     Delete the Ith element of object O.  Returns `-1' on failure.
     This is the equivalent of the Python statement `del O[I]'.

`int PySequence_SetSlice(PyObject *o, int i1, int i2, PyObject *v)'
     Assign the sequence object V to the slice in sequence object O
     from I1 to I2.  This is the equivalent of the Python statement
     `O[I1:I2] = V'.

`int PySequence_DelSlice(PyObject *o, int i1, int i2)'
     Delete the slice in sequence object O from I1 to I2.  Returns `-1'
     on failure. This is the equivalent of the Python statement `del
     O[I1:I2]'.

`PyObject* PySequence_Tuple(PyObject *o)'
     Returns the O as a tuple on success, and `NULL' on failure.  This
     is equivalent to the Python expression `tuple(O)'.

`int PySequence_Count(PyObject *o, PyObject *value)'
     Return the number of occurrences of VALUE in O, that is, return
     the number of keys for which `O[KEY] == VALUE'.  On failure,
     return `-1'.  This is equivalent to the Python expression
     `O.count(VALUE)'.

`int PySequence_Contains(PyObject *o, PyObject *value)'
     Determine if O contains VALUE.  If an item in O is equal to VALUE,
     return `1', otherwise return `0'.  On error, return `-1'.  This is
     equivalent to the Python expression `VALUE in O'.

`int PySequence_Index(PyObject *o, PyObject *value)'
     Return the first index I for which `O[I] == VALUE'.  On error,
     return `-1'.    This is equivalent to the Python expression
     `O.index(VALUE)'.

`PyObject* PySequence_List(PyObject *o)'
     Return a list object with the same contents as the arbitrary
     sequence O.  The returned list is guaranteed to be new.

`PyObject* PySequence_Tuple(PyObject *o)'
     Return a tuple object with the same contents as the arbitrary
     sequence O.  If O is a tuple, a new reference will be returned,
     otherwise a tuple will be constructed with the appropriate
     contents.

`PyObject* PySequence_Fast(PyObject *o, const char *m)'
     Returns the sequence O as a tuple, unless it is already a tuple or
     list, in which case O is returned.  Use
     `PySequence_Fast_GET_ITEM()' to access the members of the result.
     Returns `NULL' on failure.  If the object is not a sequence,
     raises `TypeError' with M as the message text.

`PyObject* PySequence_Fast_GET_ITEM(PyObject *o, int i)'
     Return the Ith element of O, assuming that O was returned by
     `PySequence_Fast()', and that I is within bounds.  The caller is
     expected to get the length of the sequence by calling
     `PySequence_Size()' on O, since lists and tuples are guaranteed to
     always return their true length.


automatically generated by info2www version 1.2.2.9