DEV Community

Leonardo Cumplido
Leonardo Cumplido

Posted on

1 1

Sixth-week blog post for PSF, GSoC 2021

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))
Enter fullscreen mode Exit fullscreen mode

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.

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free