Reputation: 127
The SWIG documentation of %pythonappend
and %pythonprepend
is too brief. I am wondering how to access the return value and input argument in those python blocks. For example, here is an example from SWIG doc:
%module example
// Add python code to bar()
%pythonprepend Foo::bar(int) %{
#do something before C++ call
%}
%pythonappend Foo::bar(int) %{
#do something after C++ call
%}
class Foo {
public:
int bar(int x);
}
How to print the input argument x
and the return values of bar
here?
Thanks!
Upvotes: 1
Views: 886
Reputation: 127
Accessing input argument:
print(args)
Accessing return value:
print(val)
Warning: I get this answer by reading the generated .py file. Unfortunately, there seems to be no official support for accessing argument and return values. This approach might break your code in future swig releases.
Upvotes: 2