Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyodide
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
pyodide
Commits
d5493955
Commit
d5493955
authored
Feb 25, 2019
by
Michael Droettboom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #316: Add convenience function for converting from nested Arrays
parent
63b6ba23
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletion
+28
-1
docs/api_reference.md
docs/api_reference.md
+15
-0
src/pyodide.py
src/pyodide.py
+13
-1
No files found.
docs/api_reference.md
View file @
d5493955
...
@@ -42,6 +42,21 @@ some preprocessing on the Python code first.
...
@@ -42,6 +42,21 @@ some preprocessing on the Python code first.
Either the resulting object or
`None`
.
Either the resulting object or
`None`
.
### pyodide.as_nested_list(obj)
Converts Javascript nested arrays to Python nested lists. This conversion can not
be performed automatically, because Javascript Arrays and Objects can be combined
in ways that are ambiguous.
*Parameters*
| name | type | description |
|--------|-------|-----------------------|
|
*obj*
| JS Object | The object to convert |
*Returns*
The object as nested Python lists.
## Javascript API
## Javascript API
...
...
src/pyodide.py
View file @
d5493955
...
@@ -67,4 +67,16 @@ def find_imports(code):
...
@@ -67,4 +67,16 @@ def find_imports(code):
return
list
(
imports
)
return
list
(
imports
)
__all__
=
[
'open_url'
,
'eval_code'
,
'find_imports'
]
def
as_nested_list
(
obj
):
"""
Assumes a Javascript object is made of (possibly nested) arrays and
converts them to nested Python lists.
"""
try
:
it
=
iter
(
obj
)
return
[
as_nested_list
(
x
)
for
x
in
it
]
except
TypeError
:
return
obj
__all__
=
[
'open_url'
,
'eval_code'
,
'find_imports'
,
'as_nested_list'
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment