Differences between revisions 1 and 2
Revision 1 as of 2008-10-29 23:59:08
Size: 885
Editor: PhilipJenvey
Comment:
Revision 2 as of 2008-11-15 09:16:02
Size: 885
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

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)