extension modules in C for python, check for korrekt Object
Michael Hudson
mwh at python.net
Wed Jun 2 05:42:34 EDT 2004
Torsten Mohr <tmohr at s.netic.de> writes:
> Hi,
>
> i write a set of extension modules for python in C.
> I also use some new types that i defined there.
>
> At the moment i write some methods that expect some
> of these types as parameters. I now want to check
> that the right types were given as parameters.
>
> How can i do that?
>
> PyArg_ParseTuple only checks that an object was
> given as parameter, but not its type.
It can check type, using the "O!" incantation.
If you're asking "how do I get hold of the type object I defined in
some other extension module?", then that's a good question. One
approach is to use "CObjects":
http://docs.python.org/ext/using-cobjects.html
> Do i need to check tp_name in the objects type?
This sounds fragile :-)
Cheers,
mwh
--
Of the four project development variables - scope, cost, time and
quality - quality isn't really a free variable. The only possible
values are "excellent" and "insanely excellent", depending on
whether lives are at stake. -- Kent Beck, XP Explained
More information about the Python-list
mailing list