[C++-sig] boost::python::dict problem
Martin Walser
martin.walser at gmx.de
Wed Oct 1 18:58:27 CEST 2008
Ralf W. Grosse-Kunstleve wrote:
> I have no explanation (other than that it looks like a bug/hole), but I'd
> expect
> testdict[boost::python::make_tuple(1, 17)] to work as you expect.
Indeed. This seems to help. :D
C++:
testdict[make_tuple(1,17)]="huhu";
testdict[(2,32)]="hooray";
string test = extract<string>(testdict[make_tuple(1,17)]); //works
mLog->log(test); //works
Python:
print self.myCExtension.testdict
print self.myCExtension.testdict[(1,17)]
results in:
Python Output:
{32: 'hooray', (1, 17): 'huhu'}
huhu
Perfect!
Access in C++ has to be done with make_tuple(x,y) as well, though (Line 3 of
C++) or it'll raise an error.
Thx Ralf!
More information about the Cplusplus-sig
mailing list