A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pyodide/pyodide/issues/1426 below:

what is a proper way to reuse intermediate object of previous execution · Issue #1426 · pyodide/pyodide · GitHub

Hi, thanks for this good tool.

In a normal python program, we can use

  1. class instantiation way
# in main program 
a = demoClass()
a.doSomething1()
# after a while
a.doSomething2() # this can use some internal object
  1. or we can use some static or global variable

I realize that every python allocated object will keep in memory and the 2nd execution of the python script can access them. However, the current implementation (pyodide.runPython) looks like it is to execute a one-time python script for the 1st time, 2nd time, 3rd time...

The only way I think of is to use like

if 'myVar' in globals():
    # it means 2nd time and do a different thing, e.g. use existing object

A little tricky, or is it possible to add one parameter for runPython to specify different behavior for the same python code in the future? Or using pyodide.eval_code_async (instead of runPythonAsync) to adjust the parameters passed into the 2nd time execution and use it to do conditional statement?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4