Please note: This wiki is currently running in test mode after an attack on January 5 2013. All passwords were reset, so you will have to use the password recovery function to get a new password. To edit wiki pages, please log in first. See the wiki attack description page for more details. If you find problems, please report them to the pydotorg-www mailing list.

CPython function

Jython method

long intobject::PyInt_AsLong(register PyObject *op)

int PyObject.asInt()

PyObject* intobject::PyInt_FromString(char *s, char **pend, int base)

PyObject PyObject.__int__()

Py_ssize_t intobject::PyInt_AsSsize_t(register PyObject *op)

int PyObject.__int__().asInt()

Py_ssize_t abstract::PyNumber_AsSsize_t(PyObject *item, PyObject *err)

int PyObject.asIndex(err)

int abstract.h::PyIndex_Check(PyObject *ob)

boolean PyObject.isIndex()

When using asInt, consider whether you want to ensure the original object is an instanceof PyInteger/PyLong prior to calling asInt on it. It's common to do this check before calling asInt, but is not required -- otherwise asInt will attempt to implicitly convert non int/longs via user defined __int__ methods.

IntegerConversion (last edited 2008-11-15 09:16:02 by localhost)