pyodide.find_imports

pyodide.find_imports(code: str)List[str]

Finds the imports in a string of code

Parameters

code – the Python code to run.

Returns

Return type

A list of module names that are imported in the code.

Examples

>>> from pyodide import find_imports
>>> code = "import numpy as np; import scipy.stats"
>>> find_imports(code)
['numpy', 'scipy']