Browse Source
This allows Python to iterate over JavaScript objects that provide Symbol.iterator. Signed-off-by: Damien George <damien@micropython.org>pull/15293/head
Damien George
5 months ago
3 changed files with 36 additions and 15 deletions
@ -0,0 +1,14 @@ |
|||
// 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))) |
|||
`);
|
@ -0,0 +1,4 @@ |
|||
1 |
|||
2 |
|||
one ['1'] |
|||
two ['2'] |
Loading…
Reference in new issue