pub fn py_new_args(py: RUMPython<'_>) -> RUMPyListExpand description
Create empty Python List, which can be used for creating a collection of arguments to pass to script.
ยงExample
use compact_str::format_compact;
use pyo3::Python;
use pyo3::types::{PyListMethods, PyAnyMethods};
use crate::rumtk_core::scripting::python_utils::{py_new_args, py_push_arg, RUMPyArgs, RUMPyList};
use crate::rumtk_core::scripting::python_utils::{py_buildargs, py_extract_string_vector};
Python::attach( |py| {
let example_arg_1 = 1;
let example_arg_2 = "Hello";
let mut py_args: RUMPyList = py_new_args(py);
py_push_arg(py, &mut py_args, &example_arg_1.clone()).unwrap();
py_push_arg(py, &mut py_args, &example_arg_2.clone()).unwrap();
let arg_1: usize = py_args.bind(py).get_item(0).unwrap().extract().unwrap();
assert_eq!(&example_arg_1, &arg_1, "{}", format_compact!("Python list does not match the input list!\nGot: {:?}\nExpected: {:?}", &arg_1, &example_arg_1));
}
)