List Info

Thread: a question about boost python




a question about boost python
user name
2007-10-16 04:23:13

Hi All

I have a set of functions which last parameters are out-parameter. i.e.

  void  function1(int  t1, float t2, string& t3) ;

I want to expose these functions in python, but such definition (~def(function1, function1)~) is not what I want.

Because we have to write python code like this:

   strTest=

   function1(1,2.0,strTest);

I prefer to writing python code like this

   strTest = funciton1(1,2.0)

Is there any idea to solve this question?

Thanks





Re: a question about boost python
user name
2007-10-16 05:23:55
On 10/16/07, Chang Chen < Chang_Chensonic.com">Chang_Chensonic.com> wrote:

Hi All

I have a set of functions which last parameters are out- pa rameter. i.e.

  void   function1(int   t1, float t2, string & t3)  ;

I want to expose these functions in python, but such defi nition (~d ef("function1 ", function1) ~) is not what I want.

Because we have to write python code like this:

 &nbsp; strTest= ''

 &nbsp; function1(1,2.0,strTest);

I prefer to writing python code like this

 &nbsp; strTest = funciton1(1,2.0)

Is there any idea to solve this question?

In short: to create another function, with the desired interface. In your case you just don't have other choice - std::string is mapped to Python string, which is immutable.

Read more here: http://language-binding.net/pyplusplus/documentation/functions/transformation/built_in/output.html

--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )