A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-October/039406.html below:

[Python-Dev] PyList API missing PyList_Pop() and PyList_Delete

[Python-Dev] PyList API missing PyList_Pop() and PyList_Delete [Python-Dev] PyList API missing PyList_Pop() and PyList_DeleteRaymond Hettinger raymond.hettinger at verizon.net
Thu Oct 23 18:38:10 EDT 2003
Was there a reason for leaving this out of the API or should it be 
added?  Is the right way to simulate a pop something like this:


n = PyList_GET_SIZE(outbasket);
if (n == 0) {
	PyErr_SetString(PyExc_IndexError, "Pop from an empty list.");
	return NULL;
}
result = PyList_Get_Item(outbasket, n-1);
if (result == NULL)
	return NULL;
Py_INCREF(result);
empty_list = Py_ListNew(0);
if (empty_list == NULL) {
      Py_DECREF(result);
      return NULL;
}
err = PyList_SetSlice(to->outbasket, n-1, n, empty_list);
Py_DECREF(empty_list);
if (err == -1) {
      Py_DECREF(result);
      return NULL;
}
return result;
/* Whew, that was a lot of code for a pop have a popped result */


Raymond Hettinger


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4