Topic was automatically imported from the old Question2Answer platform.
Asked By
brian721
I wonder if it is possible to update the dictionary with new content (funct test_init_dict) and not only update its existing content.
Using ‘test_init_dict’ in the example bellow, the dictionary is not updated.
I would use it to keep de response from a http request, in a request_completed method, passing the dictionary as parameter. For each request I could inform a different dictionary. As the http request would return either an json array or a json object, I don’t want to manually iterate the response to update the dictionary.
In your test_init_dict function, you pass in a reference value that is stored in the local variable dict. This is then replaced by a new reference value locally.
What you could do is have a dictionary key for the captured request data such as dict[“data”]. Then the update is reflected back to the external dictionary.
Also, you don’t need the onready statement unless you are waiting for the node tree to be built.
Thanks for your response,
I think having a key for the new data is a good alternative.
In my case I’ve added 3 extra parameters in the _on_request_completed, the request itself, wich will be freed at the end, the dictionary requested_data with all the responses, and the request_type that is the key where it will be stored the response.