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
@spec append(Pythonx.C.PyObject.t(), Pythonx.C.PyObject.t()) :: true | Pythonx.C.PyErr.t()
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).
@spec as_tuple(Pythonx.C.PyObject.t()) :: Pythonx.C.PyObject.t() | Pythonx.C.PyErr.t()
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.
@spec get_item(Pythonx.C.PyObject.t(), integer()) :: Pythonx.C.PyObject.borrowed() | Pythonx.C.PyErr.t()
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.
@spec get_slice(Pythonx.C.PyObject.t(), integer(), integer()) :: Pythonx.C.PyObject.t() | Pythonx.C.PyErr.t()
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.
@spec insert(Pythonx.C.PyObject.t(), integer(), Pythonx.C.PyObject.t()) :: true | Pythonx.C.PyErr.t()
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).
@spec new(integer()) :: Pythonx.C.PyObject.t() | Pythonx.C.PyErr.t()
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()
.
@spec set_item(Pythonx.C.PyObject.t(), integer(), Pythonx.C.PyObject.t()) :: true | Pythonx.C.PyErr.t()
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.
@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()
.