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

Use Boost-Python to Find Number of Arguments that Function Have

I have a user-defined function in python which I don't know how many arguments it has. i.e. It can be def f1(x,y,z): return sin(x)*cos(y)*tan(z) or def f1(x): return sin(x) How I can use Boost-Python to find how many arguments the function…
Roy
  • 65
  • 2
  • 15
  • 40
0
votes
1 answer

extending protected functions boost::python

I have C++ code (not mine, so it is not editable). Problem is with extending protected functions and class. #include "ExtraClass.h" ... MyClass::MyClass() { ... protected: bool Func{} ExtraClass m_Foo; ... } I need access in Python to m_Foo…
0
votes
1 answer

How to converter std::string* in boost.python?

How to converter std::string* in boost.python?I have to handle some data of c++ in python.The data may be big.So I return a pointer to python. But there are some errors. c++ #include #include class A { public: A() { …
simon
  • 569
  • 9
  • 20
0
votes
1 answer

Boost.Python installation failing with bjam errors

I have been struggling to get Boost.Python running . i am following the steps mentioned in http://www.boost.org/doc/libs/1_41_0/libs/python/doc/building.html . I followed section 3.1 step 2 . Bjam driver is giving my headaches . So as mentioned in…
rockstar
  • 3,512
  • 6
  • 40
  • 63
0
votes
2 answers

In boost::python how to wrap an overrideable function which takes a container of pointers to C++ objects and returns a pointer to one of them?

I'm wrapping a C++ framework with boost::python and I need to make a C++ method overrideable in python. This is a hook method, which is needed by the framework and has a default implementation in C++, which iterates through a list (passed as…
tunnuz
  • 23,338
  • 31
  • 90
  • 128
0
votes
0 answers

get type value of boost:any object to do a cast

Is there any way to get the typevalue of my boost::any object to use it for an any_cast? POSITION dictPos = CurrentSubMap->GetStartPosition(); while(dictPos) { boost::any a = CurrentSubMap->GetValueAt(dictPos); …
bob morane
  • 650
  • 1
  • 11
  • 24
0
votes
2 answers

(C++) error: invalid use of non-static member function ‘int Demo::addTwoNumbers(int, int)’

I'm trying to wrap a simple demo class with a function called "addTwoNumbers" with boost python. Here's the header file: #ifndef DEMO_H_ #define DEMO_H_ #include class Demo { public: Demo() {} virtual ~Demo() {} …
mavix
  • 2,488
  • 6
  • 30
  • 52
0
votes
1 answer

boost python wrapper in dynamic library undefined reference

I'm currently trying to put part of a complex program into a dynamic library. This part consists of some classes that are also wrapped with boost python into a module to be embedded again. Here is a simplified version of the dll…
jean-claude91
  • 167
  • 1
  • 2
  • 10
0
votes
1 answer

build python extension with boost build

I'm trying to use boost.python and build a python extension from c++. My cpp file use a function named 'BZ2_bzopen' which is in the library 'libbz2' under standard path (/usr/lib/). However, when I try to build the extension using boost build…
Jun
  • 307
  • 1
  • 2
  • 8
0
votes
1 answer

What is the required lifetime of objects returned by import() and exect_file()?

Below is a condensed form of this example: http://www.boost.org/doc/libs/1_51_0/libs/python/doc/v2/exec.html#examples Python function to call from C++, stored in the file script.py: def greet(): return 'Hello from Python!' The C++ code to…
Frank Kusters
  • 2,544
  • 2
  • 21
  • 30
0
votes
1 answer

how to use parameters of class_ from boost.python

The first question: The class_ class has four parameters. class template class_ I don't understand the parameters of Bases and HeldType.How to use the parameters. this doc:…
simon
  • 569
  • 9
  • 20
0
votes
0 answers

python module stuck

I have made a python module (with boost::python), which at some point creates an array (2D vector) of some massive objects. The total size of the objects is something like a few Gb. When starting execution of the program it hangs/stucks in the place…
user938720
  • 271
  • 3
  • 14
0
votes
1 answer

Constructing/destructing an object in external c++ module on module load/unload

I wrote a python module in c++. All works fine but now I want to add logging. My logger class (3rd party) requires initializtion similar to: int main() { Logger logger("log.log"); Logger::Register(&logger); DoSomethingAndLog(); …
Xyand
  • 4,470
  • 4
  • 36
  • 63
0
votes
1 answer

Python type exists

I have to check whether passed object type exists in python using boost python library: // bp = boost::python bool TypeExists(const std::string &typeName) { bp::object ret = bp::exec( (boost::format("'%1%' in globals()") %…
Max Frai
  • 61,946
  • 78
  • 197
  • 306
0
votes
1 answer

Accessing variable in C++ that has been wrapped in Python

How do I access a variable in C++ that has been wrapped in Python via BoostPython method like below(in this case I want to access y): boost::python::exec("y = x", main_namespace); Thanks in advance. EDIT: Assume y is an integer.
alfa_80
  • 427
  • 1
  • 5
  • 21
1 2 3
88
89