Boost logo

Boost :

Subject: [boost] [python] extracting a string and a one-length list containing a string
From: Allan Johns (allan.johns_at_[hidden])
Date: 2011-03-09 17:33:27


Hello,

Given a boost::python object, how can I the difference between that object
containing a string, or a sequence of length 1 whos zeroeth element is a
string? Ie:

"foo" --vs-- ["foo"]

bp::extract<std::string> succeeds in both cases.

I can use PySequence_Check to test for a sequence, and then I can test the
length of the zeroeth element - if >1 then it's ["foo"] - but then I still
can't disambiguate ["X"].

tia!
Allan


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk