mirror of
https://github.com/micropython/micropython.git
synced 2025-09-07 02:10:52 +02:00
This allows Python to iterate over JavaScript objects that provide Symbol.iterator. Signed-off-by: Damien George <damien@micropython.org>
15 lines
373 B
JavaScript
15 lines
373 B
JavaScript
// Test accessing JavaScript iterables (objects with Symbol.iterator) from Python.
|
|
|
|
const mp = await (await import(process.argv[2])).loadMicroPython();
|
|
|
|
mp.runPython(`
|
|
import js
|
|
|
|
for v in js.Set.new([1, 2]):
|
|
print(v)
|
|
|
|
url_search_params = js.URLSearchParams.new("one=1&two=2")
|
|
for key in url_search_params.keys():
|
|
print(key, list(url_search_params.getAll(key)))
|
|
`);
|