-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Support for accessing Python scope #67
Comments
Hi, are you asking why the We're always looking to improve the API to make it more useful, so suggestions are certainly welcome. Currently, there isn't support for directly accessing the Python scope (i.e. globals) from JavaScript, or vice versa. Ideally, I'd like to support this behaviour but due to using web workers to run the Pyodide instances, this is tricky to get working. |
My first question is why are you using python's exec function instead of a direct execution. |
To answer your first question, every execution is wrapped in some additional Python code to improve the default error handling behaviour. Getting the value of variables directly from Python (other than from stdout) is currently unsupported, so I'm unable to provide any examples of this just yet. We're looking into supporting access to globals, so once I have more to share I'll update this issue with further information. |
ok, thank you for your answer |
Hi, Very exciting project! It seems that you have a PR on accessing the Python global scope hanging around for a while #71 Thanks! |
I have forked and added the feature of getting value from To implement this, I removed the author-improved error handling, so it is just for anyone who needs to get variable values from |
According to pyodide runPython can return a value https://pyodide.org/en/stable/usage/quickstart.html?highlight=expression#running-python-code
I was looking to the code and I see that you wrap the run call into an exec method which is part of the problem here.
Right now I don't really understand why this wrapper is here and I assume that's because I'm pretty new to the python engine.
In an other hand I don't see how to get anything else then stdout and/or stderr with this hook.
I'll be happy to contribute if you think that could be a great enhancement to get the result of code execution and/or share some variables like globals for exemple.
The text was updated successfully, but these errors were encountered: