> if (obj) ...
>
> is definitely the right way to do it.
Sorry to correct, but it isn't equivalent to "obj is None".
if (obj) uses PyObject_IsTrue(); see
boost/python/object_operators.hpp line 60.
I'll add
obj.is_none()
and
obj.is_not_none()
when I get a chance.
Ralf
__
On 02/07/2010 09:32 PM, Jim Bosch wrote:
On Sun, 2010-02-07 at 11:47 +0100, Murray Cumming wrote:
And what's the correct way to check for PyNone other than
if (obj == boost::python::object())
?
I think that's the standard way. I suppose
if (obj.ptr() == Py_None)
might be faster on
On Sun, 2010-02-07 at 11:47 +0100, Murray Cumming wrote:
> Doing this
> boost::python::object obj = get_some_object();
> if(obj)
> {
> //do something
> }
> seems to check a bool value inside the underlying PyObject, though I
> guess that could throw an exception if it doesn't contain a
On Sun, Feb 7, 2010 at 8:57 PM, Neal Becker wrote:
> PyBindGen shows an example wrapping STL containers. What if I need to wrap
> my own containers? Is there some generic container machinery?
>
Yes, there is some generic container machinery, although it currently is
duplicating the STL contain
On 02/07/2010 04:51 PM, Murray Cumming wrote:
On Sun, 2010-02-07 at 09:51 -0500, Stefan Seefeld wrote:
Sorry, I don't understand the question. Can you give an example of
what
you want to do ? May be you want to "exec" some python code that
defines
a function, which you then want to extract a
Is there any easy way to get python Date, Time and DateTime values from
boost::python::objects? In C, I'm using PyDateTime_GET_YEAR(),
PyDateTime_GET_MONTH(), PyDateTime_GET_DAY(), etc, but it would be nice
to use some C++ API for this.
--
murr...@murrayc.com
www.murrayc.com
www.openismus.com
__
On Sun, 2010-02-07 at 09:51 -0500, Stefan Seefeld wrote:
>
> Sorry, I don't understand the question. Can you give an example of
> what
> you want to do ? May be you want to "exec" some python code that
> defines
> a function, which you then want to extract and call later ?
> That may look like t
PyBindGen shows an example wrapping STL containers. What if I need to wrap
my own containers? Is there some generic container machinery?
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig
PyBindGen is a Python module that is geared to generating C/C++ code that
binds a C/C++ library for Python. It does so without extensive use of either
C++ templates or C pre-processor macros. It has modular handling of C/C++
types, and can be easily extended with Python plugins. The generated code
On 02/07/2010 08:29 AM, Murray Cumming wrote:
So, I guess I can use boost::python::exec() to call code that defines a
Python function.
bpl::exec() executes a chunk of Python code, no matter what it contains.
But how can I get a boost::python::object for the (callable object of)
the functi
On Sun, 2010-02-07 at 08:03 -0500, Stefan Seefeld wrote:
> On 02/07/2010 05:22 AM, Murray Cumming wrote:
> > In Glom, to execute arbitrary Python code, I use PyRun_String() to parse
> > the Python code, PyDict_GetItemString() and PyObject_Call() to get a
> > callable object for that code, and then
On 02/07/2010 05:22 AM, Murray Cumming wrote:
In Glom, to execute arbitrary Python code, I use PyRun_String() to parse
the Python code, PyDict_GetItemString() and PyObject_Call() to get a
callable object for that code, and then PyObject_CallObject() to
actually execute the code and get a return v
Doing this
boost::python::object obj = get_some_object();
if(obj)
{
//do something
}
seems to check a bool value inside the underlying PyObject, though I
guess that could throw an exception if it doesn't contain actually
contain a bool. Is that right?
The reference documentation is not
In Glom, to execute arbitrary Python code, I use PyRun_String() to parse
the Python code, PyDict_GetItemString() and PyObject_Call() to get a
callable object for that code, and then PyObject_CallObject() to
actually execute the code and get a return value. This was the result of
experimentation and
14 matches
Mail list logo