You can use the PyList_Append()
function to add individual elements to an existing Python list
object:
Append the object item at the end of list list. Return 0
if successful; return -1
and set an exception if unsuccessful. Analogous to list.append(item)
.
Alternatively, use PyList_SetSlice()
to extend the list with items from another list
object:
Set the slice of list between low and high to the contents of itemlist. Analogous to list[low:high] = itemlist
. The itemlist may be NULL, indicating the assignment of an empty list (slice deletion). Return 0
on success, -1
on failure. Negative indices, as when slicing from Python, are not supported.