[C++-sig] Re: accessing the python type system

David Abrahams dave at boost-consulting.com
Thu May 29 19:39:09 CEST 2003

Stefan Seefeld <seefeld at sympatico.ca> writes:

> David Abrahams wrote:
>> I've been trying to say that I think the right answer is to provide a
>> boost::python::object called 'type', something like:
>>    object const type = extract<object>(PyTypeObject*);
>> so you could do:
>>    object y = type(x);
> oh, now I understand (at least partly). But this last line really
> *creates* a type object given another object. So I don't understand
> why 'type' has to be an object. Why not simply make it a function ?

Because it's an object in Python.  You should be able to say:

        if (x.attr("__class__") == type)
            // whatever

for example.  Or



> Users' expectations would still be satisfied (the last line above
> would still be valid), 

Not all of them.

Dave Abrahams
Boost Consulting

More information about the Cplusplus-sig mailing list