>>> isinstance(3, int)
True
See here for more.
Note that this does not help if you're looking for int
-like attributes. In this case you may also want to check for long
:
>>> isinstance(3L, (long, int))
True
I've seen checks of this kind against an array/index type in the Python source, but I don't think that's visible outside of C.
Token SO reply: Are you sure you should be checking its type? Either don't pass a type you can't handle, or don't try to outsmart your potential code reusers, they may have a good reason not to pass an int to your function.