Files
hakorune/examples/py_callKwR_ok_demo.hako

23 lines
634 B
Plaintext

// Python callKwR OK demo (returns Result.Ok(value))
// @env NYASH_PLUGIN_ONLY=1
// @env NYASH_PY_AUTODECODE=1
// Run:
// ./target/release/nyash --backend vm examples/py_callKwR_ok_demo.hako
static box Main {
main() {
local py, bi, dictf, r
py = new PyRuntimeBox()
bi = py.import("builtins")
dictf = bi.getattr("dict")
// dict(a=1, b=2) => {'a': 1, 'b': 2}
r = dictf.callKwR("a", 1, "b", 2)
me.console.println(r) // expect Ok(PyObjectBox(...))
// For readability, also show string form via .str()
local s
s = dictf.callKw("a", 1, "b", 2).str()
me.console.println(s)
return 0
}
}