You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a Jupyterlite with slightly customized Pyodide environment, I failed to access value of a global variable.
In UI, I ran the following assignment statement in a cell:
a=1
In some customized code, I ran the following Typescript code for testing:
const{ globals }=this._pyodide;consta_before=globals.get("a");if(a_before)try{console.log(`Before run, the value is ${a_before}.`);}catch(err: any){console.error(err);console.log(`Before run, the value is ${a_before.toJS()}.`);}awaitthis._pyodide.loadPackagesFromImports(newCode);constresult=awaitthis._pyodide.runPythonAsync(newCode);if(result)console.log(`After run, the result is ${result}`);consta_after=globals.get("a");if(a_after)try{console.log(`After run, the value is ${a_after}.`);}catch(err: any){console.error(err);console.log(`After run, the value is ${a_after.toJS()}.`);}
It failed to get the value of the global variable. But if the newCode assigned some value to vaiable "a", then the globals.get("a") would succeed afterwards.
It seems the namespace of Pyodide kernel is independent to that of pyodide.runPythonAsync().
Please clarify.
Thanks,
The text was updated successfully, but these errors were encountered:
In future, the code will be run in a Jupyterlab frontend extension. For example, to let AI explain code along with the current values of the used global variables.
In a Jupyterlite with slightly customized Pyodide environment, I failed to access value of a global variable.
In UI, I ran the following assignment statement in a cell:
In some customized code, I ran the following Typescript code for testing:
It failed to get the value of the global variable. But if the newCode assigned some value to vaiable "a", then the globals.get("a") would succeed afterwards.
It seems the namespace of Pyodide kernel is independent to that of pyodide.runPythonAsync().
Please clarify.
Thanks,
The text was updated successfully, but these errors were encountered: