[C++-sig] boost::python::dict problem
Ralf W. Grosse-Kunstleve
rwgk at yahoo.com
Wed Oct 1 17:34:19 CEST 2008
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.
----- Original Message ----
From: Martin Walser <martin.walser at gmx.de>
To: c++-sig at python.org
Sent: Wednesday, October 1, 2008 6:00:23 AM
Subject: [C++-sig] boost::python::dict problem
Hello! :)
Hmm... something odd's happening here when I'm trying to use a dict in my
boost python C++ Extension:
C++ Extension Code:
dict testdict;
...
testdict[1,17]="huhu";
string test = extract<string>(testdict[1,17]); //access to
dict: works!
mLog->log(test); //writes test string to log... output: "huhu":
works!
But if I want to access the testdict class member in Python like here:
Python Code:
print self.myCExtension.testdict
I get this output:
{17: 'huhu'}
While it should be {(1,17): 'huhu'}
Doing this with a bigger dict results in a output were most entries are
missing.
When I output them in C++ all are there.
Accessing with self.myCExtension.testdict[1,17] in python doesn't work
either of course:
KeyError: (1, 17)
Hum...
ravening beast... this boost::python.
Martin
_______________________________________________
C++-sig mailing list
C++-sig at python.org
http://mail.python.org/mailman/listinfo/c++-sig
More information about the Cplusplus-sig
mailing list