Fixed children retrieving from python collections by javascript. #3
+9
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've stuck with a problem recently with python collections and accessing them from javascript.
Say you have a JSON object (python dict)
When you pass it to javascript, it has a problem accessing some fields from it.
For example, if you would like to print whole python dict from javascript, it prints OK, but if you try to access some childs, corresponding methods may be returned instead.
For example, dict has a method
items
. So if you try to accessdict["items"]
from javascript, you will end up with a reference to such method, instead of child with name "items".This pull request reverses the order of querying items from python object: first, if the object is a python collection, it tries to pull that item. Then, a corresponding field is tried to be pulled.
I understand that there would be no way to access function
dict.items
from now on, if there's a child with such name. But this problem only occurs to python collections, and this method is kinda useless sincefor (var i in dict)
gives what you want. Also, printing whole dict returns childs instead of methods, so return[1, 2, 3]
instead of[Function function]
should be kinda expected result.