Questions tagged [boost-python]

Library for intuitive and tight integration between C++ and Python.

Boost::python is a C++ library offering seamless integration of C++ and Python with reference handling, built-in and user-defined two-way type conversions, Python/C++ exception translation, function overloading, exposing class hierarchies, docstring support and more.

1337 questions
0
votes
2 answers

Boost Python binding Vector of a Class

I am trying to create a python binding for a C++ class using Boost Python #include #include #include using namespace boost::python; struct World { void…
z33m
  • 5,993
  • 1
  • 31
  • 42
0
votes
1 answer

Pycuda installation on Ubuntu

I'm having a difficult time installing pycuda. I am running on Ubuntu 12.04. I first installed the Enthought python distribution (even though I already had python on the computer). I added the enthought python location to the path in my .profile…
miz
  • 185
  • 2
  • 10
0
votes
1 answer

boost python - how to send a raw pointer to a python function>

I have python embedded in my application and I want to send a python function a raw pointer to an object I have in my C++ code. The only way I found how to do this is to wrap the pointer with an auto_ptr or a shared_ptr but I prefer not to do that…
shoosh
  • 76,898
  • 55
  • 205
  • 325
0
votes
1 answer

Can't bind function that returns const char *

Using Boost.Python, I can't seem to be able to bind any function that returns a const char* example: class Bar { private: int x; public: Bar():x(0){} Bar(int x) : x(x) {} int get_x() const { return x; } void set_x(int x) { this->x =…
iabdalkader
  • 17,009
  • 4
  • 47
  • 74
0
votes
1 answer

Properly overload double equals for a class deriving from std::vector

I have a class class Item { int _one; int _two; int _three; // other stuff }; class ItemList : public std::vector { // deriving from std vector because the ctor needs to // perform some work in discriminating what gets…
Andrew Falanga
  • 2,274
  • 4
  • 26
  • 51
0
votes
1 answer

Pure virtual overload operator in Boost.Python wrapper

I'm writing a wrapper class for an abstract base class, the base class has a couple of pure virtual methods and an overloaded operator, if I compile with the overloaded operator I get the following error: cannot allocate an object of abstract…
iabdalkader
  • 17,009
  • 4
  • 47
  • 74
0
votes
1 answer

'in' operator with boost::python

I have a class which .defines the __getitem__, __setitem__ methods (and keys and items as well), and behaves like a dictionary, where keys are strings. However, the in operator does not behave as expected: >>> myObject=MyClass() >>> 'abc' in…
eudoxos
  • 18,545
  • 10
  • 61
  • 110
0
votes
1 answer

Wrap int pointer member variable in boost.python/pyplusplus

If I am using boost.python or pyplusplus, how do I wrap an int pointer, or any pointer that is a member variable of a class? For example, how would I wrap x from the following class: class Foo{ int * x; }
user810973
  • 161
  • 8
-1
votes
1 answer

How can I create an instance of RuntimeError in boost python?

I have a requirement to create, but not throw, a python RuntimeError. I'm using Boost python, the code so far: static boost::python::object builtins = boost::python::import("builtins"); static boost::python::object object =…
P45 Imminent
  • 8,319
  • 4
  • 35
  • 78
-1
votes
1 answer

missing arguments in __init__ when using using multiprocessing with a python object that uses a C++ class as base class

I have a class Node in C++ that I exposed to python using Boost/Python (yes, I know that Node is small but I translated it because some pretty big classes are derived from it). According to the boost/python documentation, I should be able to do this…
qwerty_99
  • 640
  • 5
  • 20
-1
votes
1 answer

SWIG Or Boost -for Mapping C structures to Python

I have requirement to map C Structures to Python. Any suggestion what will be the best approach to go for SWIG or Boost with least complexity.
Hi...
  • 15
  • 4
-1
votes
1 answer

(Boost.Python) Segmentation fault when quitting Python 3 after importing a boost python module

I am currently facing a problem while testing a Boost Python Module. It's a basic wrapper of a C++ class, I can use it in Python without any problems (instance, access to its attributes, etc) but when I quit the Python environment, I got a…
adem.sh
  • 169
  • 13
-1
votes
1 answer

Using C++ DLLs in Python

I'm sorry if the question seems repeated many times here but I spent the whole day without finding a clear answer. I'm working under Visual Studio 2010 and i'm trying to load a class defined in a DLL into Python. I saw that there's no way to do this…
M.Moncif
  • 11
  • 4
-2
votes
1 answer

Wrap matrix multiplication with operator* overload

I have been trying to wrap a matrix c++ class to be called in python. I would like to be able to call the matrix multiplication using the rich multiply operator (ie. m1 * m2) but so far have only managed to bind a function m3 = multiply(m1, m2)…
jackw11111
  • 1,457
  • 1
  • 17
  • 34
-3
votes
1 answer

How can i use ofstream in class that is wrapped with Boost.Python to Python?

I changed the code one month ago and im stucking at the same error which i described below. I dont find a pretty simple example how to expose an fstream object with Boost.Python to Python to solve my explained problem In short words i just want to…
Flo
  • 155
  • 1
  • 11
1 2 3
88
89