MD <[EMAIL PROTECTED]> writes:

> 2) Is there anyway to find the type of the object in C using something
> like a switch statement? I was looking for something like this
>    switch type(object) {
>       STRING: "This is a string object";
>               break;
>       INTEGER: "This is an integer object";
>               break;
>       BOOLEAN: "This is a boolean object";
>       .........
>       .........
>       }

Not switch, but the closest you'll get is:

if (object->ob_type == PyString_Type) {
  ... string
}
else if (object->ob_type == PyInt_Type) {
  ... int
}
else if (object->ob_type == PyBool_Type) {
  ... bool
}

> I don't want to run all the C Py***_Check functions on the object.

Py*_Check are not expensive if the object really is of the target
type.  They are necessary to support subtyping correctly.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to