[C++-sig] Re: converting dict value to object

David Abrahams dave at boost-consulting.com
Tue Sep 16 17:06:13 CEST 2003


yakumoklesk at yahoo.es writes:

> Suposing that dictio is a dict boost.python object, making this
>
> dictio['a'] = 3;
>
> it's ok, supossiing that "a" exists in the dictionary. But how can I retieve 
> the value? How can I extract an integer or converting the object_item 
> returnend by dictio['a'] into a boost.python object?
>
> py:object integer_object = 
> CONVERSION_FROM_OBJECT_ITEM_TO_OBJECT(dictio['a']);
>
> How can I do the 
> CONVERSION_FROM_OBJECT_ITEM_TO_OBJECT?
>
> Thanks.
>
> David Lucena.

py::object integer_object = dictio['a'];

> PD.- BTW, Is there any documentation/examples explaining conversion 
> policies? It's a little bit hard for me understanding such conversions.

http://www.boost.org/libs/python/doc/v2/CallPolicies.html

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





More information about the Cplusplus-sig mailing list