C api and checking for integers

lallous lallous at lgwm.org
Thu Nov 12 04:28:32 EST 2009


Hello,

I am a little confused on how to check if a python variable is an integer or 
not.

Sometimes PyInt_Check() fails and PyLong_Check() succeeds.

How to properly check for integer values?

OTOH, I tried PyNumber_Check() and:

(1) The doc says: Returns 1 if the object o provides numeric protocols, and 
false otherwise. This function always succeeds.

What do they mean: "always succeeds" ?

(2) It seems PyNumber_check(py_val) returns true when passed an instance!

Please advise.

--
Elias 




More information about the Python-list mailing list