pyo3/extensions/inheritance.rs

21 lines
545 B
Rust
Raw Normal View History

#![crate_type = "dylib"]
#[macro_use] extern crate cpython;
py_module_initializer!(inheritance, initinheritance, PyInit_inheritance, |py, m| {
try!(m.add(py, "__doc__", "Module documentation string"));
let base_class = try!(
m.add_type::<()>(py, "BaseClass")
.doc("Type doc string")
.finish());
for i in 1..10 {
try!(
m.add_type::<()>(py, &format!("C{}", i))
.base(&base_class)
.doc(&format!("Derived class #{}", i))
.finish());
}
Ok(())
});