How to expose...
Contents
-
How to expose...
- static class data members
- static class functions
- module level objects
- mutable C++ object
- std::C++ container
- "Raw" function
- "Raw" constructor
- getter and setter methods as a property
- named constructors / factories (as Python initializers)
- boost.function objects
- a package within a single extension module
-
How to get...
- C++ object from Python
- SWIG exposed C++ object from Python
- Multithreading Support for my function
- ownership of C++ object
- ownership of C++ object extended in Python
- python object from derived C++ object
- python object from extended C++ object
- access to a Python extension in the same app that embeds Python?
- How to make...
- Howto debug your extensions..
static class data members
object x_class
= class_<X>("X")
.def( ... )
...
;
x_class.attr("fu") = X::fu;
x_class.attr("bar") = X::bar;
...Since version 1.30 you can use class_ method:
.add_static_property("name", &fget [,&fset])
static class functions
It's likely to be in 1.30 release.
Meanwhile you should do something which mirrors pure Python:
class foo(object):
def f(x,y):
return x*y
f = staticmethod(f)