Dear all,

I want to export a boost::python::dict containing a boost::python::list. However, when I print this list in Python, I get an unlimited output of some strange numbers:

namespace bp = boost::python;

class readraw
{
....

                bp::list mk_pyPeak_list()
                {
                        bp::list py_peak_list;
                        for (int i = 0; i < peak_number; i++)
                        {
py_peak_list.append(bp::make_tuple(peak_list[0][i].mz, peak_list[0][i].intensity));
                        }
                        return py_peak_list;
                }

                bp::dict peak_list_info()
                {
                        bp::dict info;
                        //bp::object pn = peak_number;
                        //info["peakNumber"] = peak_number;
                        //std::cout << 
bp::extract<int>(mk_pyPeak_list().attr("__len__")();
                        bp::list l(mk_pyPeak_list());
                        info["peakList"] = l;

                        return info;
                }
        };

BOOST_PYTHON_MODULE(readraw)
{
        bp::class_<readraw>("readraw", bp::init<int>())
                .def("add_peak", &readraw::add_peak)
                .def("peak_list_info", &readraw::peak_list_info)
                .def("average_scans", &readraw::average_scans)
                ;

In Python:
>>> print rawfilereader.peak_list_info()

Results in smth. like:
...
(-431602080.0, -6.2774385622041925e+66), (-431602080.0, -6.2774385622041925e+66 ), (-431602080.0, -6.2774385622041925e+66), (-431602080.0, -6.2774385622041925e+ 66), (-431602080.0, -6.2774385622041925e+66), (-431602080.0, -6.2774385622041925 e+66), (-431602080.0, -6.2774385622041925e+66), (-431602080.0, -6.27743856220419 25e+66), (-431602080.0, -6.2774385622041925e+66), (-431602080.0, -6.277438562204 1925e+66), (-431602080.0, -6.2774385622041925e+66), (-431602080.0, -6.2774385622 041925e+66), (-431602080.0, -6.2774385622041925e+66), (-431602080.0, -6.27743856
...

What am I doing wrong?

Thanks for the help,
Ronny

_______________________________________________
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to