MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / new

Method new

src/objects/module.rs:37–40  ·  view source on GitHub ↗

Create a new module object with the `__name__` attribute set to name.

(py: Python, name: &str)

Source from the content-addressed store, hash-verified

35impl PyModule {
36 /// Create a new module object with the `__name__` attribute set to name.
37 pub fn new(py: Python, name: &str) -> PyResult<PyModule> {
38 let name = CString::new(name).unwrap();
39 unsafe { err::result_cast_from_owned_ptr(py, ffi::PyModule_New(name.as_ptr())) }
40 }
41
42 /// Import the Python module with the specified name.
43 pub fn import(py: Python, name: &str) -> PyResult<PyModule> {

Callers

nothing calls this directly

Calls 2

as_ptrMethod · 0.45

Tested by

no test coverage detected