[C++-sig] object(PyObject*) ?

David Abrahams dave at boost-consulting.com
Fri Dec 20 16:35:39 CET 2002


Jacek Generowicz <jacek.generowicz at cern.ch> writes:

> I'm trying to translate some BPLv1 code to v2. In order to do this in
> as small steps as possible, I feel the need for a way to convert
> PyObject* to python::object (to allow me to leave bits of the old
> implementation unchanged while fiddling with some unrelated bits).
>
> (Is this a misguided thing to do ?)
>
> Is there a way of achieving it ?

Yeah, it's a 2-step process:

1. convert to handle<>
2. convert handle<> to object

In step 1 use borrowed() if you need to borrow a reference.

-- 
                       David Abrahams
   dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution





More information about the Cplusplus-sig mailing list