MCPcopy Create free account
hub / github.com/bedroombuilds/python2rust / main_

Function main_

16_python_inside_rust/rust/py_in_rust/src/main.rs:14–22  ·  view source on GitHub ↗
(py: Python)

Source from the content-addressed store, hash-verified

12}
13
14fn main_(py: Python) -> PyResult<()> {
15 let sys = py.import("sys")?;
16 let version: String = sys.get("version")?.extract()?;
17 let locals = [("os", py.import("os")?)].into_py_dict(py);
18 let code = "os.getenv('USER') or os.getenv('USERNAME') or 'Unknown'";
19 let user: String = py.eval(code, None, Some(&locals))?.extract()?;
20 println!("Hello {}, I'm Python {}", user, version);
21 Ok(())
22}

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected