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

Method call

src/objects/module.rs:126–137  ·  view source on GitHub ↗

Calls a function in the module. This is equivalent to the Python expression: `getattr(module, name)(*args, **kwargs)` `args` should be a value that, when converted to Python, results in a tuple. For this purpose, you can use: `cpython::NoArgs` when calling a method without any arguments otherwise, a Rust tuple with 1 or more elements # Example ``` use cpython::NoArgs; # use cpython::Python; # le

(
        &self,
        py: Python,
        name: &str,
        args: A,
        kwargs: Option<&PyDict>,
    )

Source from the content-addressed store, hash-verified

124 /// sys.call(py, "setrecursionlimit", (1000,), None).unwrap();
125 /// ```
126 pub fn call<A>(
127 &self,
128 py: Python,
129 name: &str,
130 args: A,
131 kwargs: Option<&PyDict>,
132 ) -> PyResult<PyObject>
133 where
134 A: ToPyObject<ObjectType = PyTuple>,
135 {
136 self.as_object().getattr(py, name)?.call(py, args, kwargs)
137 }
138
139 /// Adds a member to the module.
140 ///

Callers

nothing calls this directly

Calls 2

getattrMethod · 0.80
as_objectMethod · 0.45

Tested by

no test coverage detected