cpython::py_argparse!
[−]
[src]
macro_rules! py_argparse { ($py:expr, $fname:expr, $args:expr, $kwargs:expr, ($( $pname:ident : $ptype:ty ),*) $body:block) => { ... }; }
This macro is used to parse a parameter list into a set of variables.
Syntax: py_argparse!(py, fname, args, kwargs, (parameter-list) { body })
py: thePythontokenfname: expression of typeOption<&str>: Name of the function used in error messages.args: expression of type&PyTuple: The position argumentskwargs: expression of typeOption<&PyDict>: The named argumentsparameter-list: a comma-separated list of Rust parameter declarations (name: type). The types used must implement theExtractPyObjecttrait.body: expression of typePyResult<_>.
py_argparse!() expands to code that extracts values from args and kwargs and assigns
them to the parameters. If the extraction is successful, py_argparse!() evaluates
the body expression (where the extracted parameters are available) and returns the result
value of the body expression.
If extraction fails, py_argparse!() returns a failed PyResult without evaluating body.