Subject: [boost] [python] Making a Python tuple from a Fusion sequence
From: Bruno Lalande (bruno.lalande_at_[hidden])
Date: 2009-02-23 06:32:38
I have written a little function that converts any Boost.Fusion
sequence into a Python tuple (boost::python::tuple). If a sub-sequence
is nested in the sequence, the result will also be a nested tuple (for
instance, boost::make_tuple(0, std::make_pair(1, 2), 3) will give (0,
(1, 2), 3) in Python).
The source code is attached to this mail.
The principle is that any sequence previously adapted to Boost.Fusion
will become a tuple in Python. So, by including the right
boost/fusion/adapted/xxx header, one can convert a pair, a tuple, a
boost::array, and obviously any of the sequences provided by
Boost.Fusion. For example:
using namespace boost::python;
boost::make_tuple('a', 'b', 'c'),
In Python we get:
>>> import mymodule
(1, ('first', 'second'), 2, ('a', 'b', 'c'), 3)
Is there any interest in adding this function into Boost.Python? If
yes, I can write the doc and tests, clean the source and maybe improve
the implementation (for example, I feel that I could avoid the use of
m_iteration with a better use of Boost.Fusion...).
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk