[C++-sig] Avoiding implicit boost::python::extract<> conversions

2011-04-07 Thread Murray Cumming
It looks like boost::python::extract::check() will happily succeed on an int python object, and boost::python::extract::check() will likewise succeed on a bool python object. Is there an easy way to discover the actual python type so I can really get the data I want in the correct type? -- murr.

[C++-sig] Generating API documentation when using boost::python

2010-04-15 Thread Murray Cumming
I tried running pydoc on my python module, (implemented here http://git.gnome.org/browse/glom/tree/glom/python_embed/python_module/py_glom_module.cc#n35 ) but the output has lots of stuff that is uninteresting to Python coders, even after using docstring_options. For instance: http://www.murrayc.co

Re: [C++-sig] boost::python and Date/Time values

2010-02-11 Thread Murray Cumming
On Sun, 2010-02-07 at 22:59 +0100, Murray Cumming wrote: > 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

Re: [C++-sig] Getting object for PyObject (reference counting)

2010-02-11 Thread Murray Cumming
On Fri, 2009-02-27 at 15:18 -0800, Alex Mohr wrote: [snip] > If you have a PyObject *p and you want a bp::object, > construct it via: > > object(handle<>(p)) // when p's a new reference I find that I have to split the handle and object over two lines. If I do this boost::python::obj

[C++-sig] boost::python and Date/Time values

2010-02-07 Thread Murray Cumming
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 __

Re: [C++-sig] Executing python code from C++

2010-02-07 Thread Murray Cumming
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

Re: [C++-sig] Executing python code from C++

2010-02-07 Thread Murray Cumming
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 fo

[C++-sig] Checking for or null PyObject* or PyNone

2010-02-07 Thread Murray Cumming
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

[C++-sig] Executing python code from C++

2010-02-07 Thread Murray Cumming
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

Re: [C++-sig] Getting the wrapped C++ instance from a boost::python::object

2010-02-06 Thread Murray Cumming
On Sat, 2010-02-06 at 12:54 -0500, Stefan Seefeld wrote: > On 02/06/2010 08:39 AM, Murray Cumming wrote: > > If I have a boost::python::object that I know contains a PyObject that > > wraps an instance of my C++ class, MyClass, can I get a pointer to that > > MyClass instance

[C++-sig] Getting the wrapped C++ instance from a boost::python::object

2010-02-06 Thread Murray Cumming
If I have a boost::python::object that I know contains a PyObject that wraps an instance of my C++ class, MyClass, can I get a pointer to that MyClass instance, so I can call its C++ methods? -- murr...@murrayc.com www.murrayc.com www.openismus.com ___

[C++-sig] Getting a b::p::object for a PyObject and vice-versa.

2010-02-04 Thread Murray Cumming
Can someone confirm that this is correct: 1. To get a boost::python::object that wraps an existing PyObject* (when you get a PyObject from a C function not wrapped in boost::python), can someone confirm that this is correct: Either: a) PyObject* c_object = get_the_c_object(); //returns a referen

[C++-sig] boost::python without exceptions?

2009-03-10 Thread Murray Cumming
Is there any version of the boost::python API that doesn't use exceptions? I have an environment that disables exceptions in the C++ compiler, but I'd like to use boost::python there. -- murr...@murrayc.com www.murrayc.com www.openismus.com ___ Cpluspl

Re: [C++-sig] Getting object for PyObject (reference counting)

2009-02-27 Thread Murray Cumming
On Fri, 2009-02-27 at 08:34 -0800, Alex Mohr wrote: > Murray Cumming wrote: > > I can't find any definitive documentation that tells me how I should get > > a boost::python::object to wrap an existing PyObject*. I guess that > > there's a way to do it that uses a

Re: [C++-sig] Getting object for PyObject (reference counting)

2009-02-27 Thread Murray Cumming
t*. I guess that > there's a way to do it that uses an existing reference, and a way that > takes an extra reference. > -- Murray Cumming murr...@murrayc.com www.murrayc.com www.openismus.com ___ Cplusplus-sig mailing list Cplusplus-si

[C++-sig] Getting object for PyObject (reference counting)

2009-02-27 Thread Murray Cumming
I can't find any definitive documentation that tells me how I should get a boost::python::object to wrap an existing PyObject*. I guess that there's a way to do it that uses an existing reference, and a way that takes an extra reference. -- murr...@murrayc.com www.murrayc.com www.openismus.com _

Re: [C++-sig] [] subscript notation with boost::python

2009-02-24 Thread Murray Cumming
On Mon, 2009-02-23 at 19:38 +0100, Maik Beckmann wrote: > troy d. straszheim schrieb am Montag 23 Februar 2009 um 19:15: > > > Murray Cumming schrieb am Montag 23 Februar 2009 um 12:39: > > >> I'm trying to support this notation in python: > > >> somet

[C++-sig] [] subscript notation with boost::python

2009-02-23 Thread Murray Cumming
"Boost.Python.class' object is unsubscriptable" Is there something else that I need to do? -- Murray Cumming murr...@murrayc.com www.murrayc.com www.openismus.com ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig