logo       

Re: accessing the python type system: msg#00344

python.c++

Subject: Re: accessing the python type system

Stefan Seefeld <seefeld@xxxxxxxxxxxx> 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

type.attr("__doc__")

or...

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

Not all of them.

--
Dave Abrahams
Boost Consulting
www.boost-consulting.com


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise