Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the README to include the correct module code. #1

Open
mgermaine93 opened this issue May 15, 2024 · 0 comments
Open

Update the README to include the correct module code. #1

mgermaine93 opened this issue May 15, 2024 · 0 comments

Comments

@mgermaine93
Copy link

Hi Cheukting,

Thanks so much for hosting the "Writing Python Modules in Rust" tutorial at PyCon 2024! I was able to follow along in the README for the most part, but ran into trouble whenever I needed to add the module code in lib.rs, specifically the parts like this (I kept getting "Not Found in this Scope" errors):

/// A Python module implemented in Rust.
#[pymodule]
fn pyo3_101(m: &Bound<'_, PyModule>) -> PyResult<()> {
    m.add_function(wrap_pyfunction!(say_hello, m)?)?;
    m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;
    Ok(())
}

After talking with someone else in the audience, I found that this code worked instead for me:

/// A Python module implemented in Rust.
#[pymodule]
fn pyo3_101(_py: Python, m: &PyModule) -> PyResult<()> {
    m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;
    m.add_function(wrap_pyfunction!(say_hello, m)?)?;
    Ok(())
}

Not sure if other people have had the same issue. I'm brand new to Rust, so hopefully this helps more people get up and running.

Thanks again!

~Matt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant