View Source Pythonx.C.PyList (Pythonx v0.2.2)

This subtype of PyObject represents a Python list object.

Summary

Functions

Append the object item at the end of list list.

Return a new tuple object containing the contents of list;

Return true if p is a list object or an instance of a subtype of the list type.

Return true if p is a list object, but not an instance of a subtype of the list type.

Return the object at position index in the list pointed to by list.

Return a list of the objects in list containing the objects between low and high.

Insert the item item into list list in front of index index.

Return a new list of length len on success, or PyErr on failure.

Reverse the items of list in place.

Set the item at index index in list to item. Return true on success.

Set the slice of list between low and high to the contents of itemlist.

Return the length of the list object in list; this is equivalent to len(list) on a list object.

Sort the items of list in place.

Functions

Append the object item at the end of list list.

Return true if successful; return PyErr with an exception if unsuccessful.

Analogous to list.append(item).

Return a new tuple object containing the contents of list;

equivalent to tuple(list).

Return value: New reference

@spec check(Pythonx.C.PyObject.t()) :: boolean()

Return true if p is a list object or an instance of a subtype of the list type.

This function always succeeds.

@spec check_exact(Pythonx.C.PyObject.t()) :: boolean()

Return true if p is a list object, but not an instance of a subtype of the list type.

This function always succeeds.

Return the object at position index in the list pointed to by list.

The position must be non-negative; indexing from the end of the list is not supported.

If index is out of bounds (<0 or >=len(list)), return PyErr

Return value: Borrowed reference.

Link to this function

get_slice(list, low, high)

View Source

Return a list of the objects in list containing the objects between low and high.

Return PyErr with an exception if unsuccessful.

Analogous to list[low:high].

Indexing from the end of the list is not supported.

Return value: New reference.

Link to this function

insert(list, index, item)

View Source

Insert the item item into list list in front of index index.

Return true if successful; return PyErr with an exception if unsuccessful.

Analogous to list.insert(index, item).

Return a new list of length len on success, or PyErr on failure.

Note

If len is greater than zero, the returned list object’s items are set to NULL. Thus you cannot use abstract API functions such as PySequence_SetItem() or expose the object to Python code before setting all items to a real object with PyList_SetItem().

Return value: New reference.

@spec reverse(Pythonx.C.PyObject.t()) :: boolean()

Reverse the items of list in place.

Return true on success, false on failure.

This is equivalent to list.reverse().

Link to this function

set_item(list, index, item)

View Source

Set the item at index index in list to item. Return true on success.

If index is out of bounds, return PyErr with an IndexError exception.

Note: This function "steals" a reference to item and discards a reference to an item already in the list at the affected position.

Link to this function

set_slice(list, low, high, itemlist)

View Source
@spec set_slice(
  Pythonx.C.PyObject.t(),
  integer(),
  integer(),
  Pythonx.C.PyObject.t() | nil
) :: boolean()

Set the slice of list between low and high to the contents of itemlist.

Analogous to list[low:high] = itemlist.

The itemlist may be nil, indicating the assignment of an empty list (slice deletion).

Return true on success, false on failure.

Indexing from the end of the list is not supported.

@spec size(Pythonx.C.PyObject.t()) :: integer()

Return the length of the list object in list; this is equivalent to len(list) on a list object.

@spec sort(Pythonx.C.PyObject.t()) :: boolean()

Sort the items of list in place.

Return true on success, false on failure.

This is equivalent to list.sort().