Inline Python code directly in your Rust code.
Example
use python;
How to use
Use the python!{..}
macro to write Python code direcly in your Rust code.
You'll need to add #![feature(proc_macro_hygiene)]
, and use a nightly
version of the compiler that supports this feature.
Tokens
The tokens need to be valid rust tokens, which means you cannot use
single-quoted strings, should use //
-comments instead of #
-comments,
cannot use u""
-strings, etc.
A later version of this crate will provide workarounds for some of these things.
Using Rust variables
To reference rust variables, use 'var
, as shown in the example above.
var
needs to implement [pyo3::ToPyObject
].
Getting information back
Right now, this crate provides no easy way to get information from the Python code back into Rust. Support for that will be added in a later version of this crate.