This content originally appeared on DEV Community and was authored by Leonardo Cumplido
Welcome to my sixth blog post about my experience in Google Summer of Code (GSoC) 2021.
What am I working on
Last week I finished working with my second milestone. This is what I did. There is a lecture in the project called Hackeando con Pyhton that is supposed to teach how to access an API and retrieve information using pyhton. Before last week, this lecture had only one exercise because others were eliminated due to the APIs they used (They have changed a lot and they are no longer public). Now, this lecture has six new exercises.
You might know these two python modules to do HTTP requests: urllib
and requests
. For the new exercises I used both, mainly because I encountered a problem with Runestone and I had to change the python interpreter to solve this.
This week I will be working on my third milestone.
What have I struggled with this week?
I had trouble with the dumps
method from the json
module. For an exercise I needed to display on screen the json data retrieved from an API. In order to print it with indentation I passed the indent
argument. Like this:
print(json.dumps(datos, indent=4))
However, it wasn't working.
What solutions have I found?
So, I was using requests
module before this. I had to change the python interpreter to brython
for some exercises, because in Brython json.dumps
with the indent
arg works just fine, but Brython doesn't support the requests
module yet. This is why I changed to urllib
. In the Brython's console, the output finally dislplayed nicely with indentation.
This content originally appeared on DEV Community and was authored by Leonardo Cumplido
Leonardo Cumplido | Sciencx (2021-07-13T17:47:54+00:00) Sixth-week blog post for PSF, GSoC 2021. Retrieved from https://www.scien.cx/2021/07/13/sixth-week-blog-post-for-psf-gsoc-2021/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.