[C++-sig] boost::python::dict problem

Littil Dummy NurEinDummy at gmx.de
Thu Oct 2 01:07:58 CEST 2008


Hm.
I don't get why "1,17" evaluates to 17 in c++.

And if it does... this still doesn't explain why the dict contained 255*255
= 65000 =len(testdict) entries in C++ but only 255 entries when querying the
length of it from within python. Removed duplicates?

Martin

-----Ursprüngliche Nachricht-----
Von: c++-sig-bounces+nureindummy=gmx.de at python.org
[mailto:c++-sig-bounces+nureindummy=gmx.de at python.org] Im Auftrag von Ravi
Gesendet: Mittwoch, 1. Oktober 2008 21:10
An: Development of Python/C++ integration
Betreff: Re: [C++-sig] boost::python::dict problem

On Wednesday 01 October 2008 09:00:23 Martin Walser wrote:
>         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!

This is a bug in your code. test[1,17] is actually test[17] since C++ rules 
for evaluating the expression "1,17" results in the value 17. I would not 
expect C++ to follow python rules and make it into a tuple. Even "(1,17)" 
would still evaluate in C++ to 17. You need, as Ralf pointed out, make_tuple

or something else that returns a python tuple rather than an expression that

returns a single int.

Regards,
Ravi


_______________________________________________
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