Exercise

Streaming records

In an earlier exercise, you codified the schema of products being sold by a store that you got from the marketing team’s REST API. If you don’t remember it, check the schema in this exercise. Now it’s time to stream some data to go with it.

A convenience function, retrieve_products(), has been made available to you. It basically executes the last step of the previous exercise: it requires one positional argument, the name of a shop, and will return a list of all products related to that shop.

This exercise is pushing you to use unpacking, using the ** operator, as shown in the video. If it’s the first time you encounter the unpacking operator, fear not: there’s a first time for everything. We want to show it to you because you will encounter it in your colleagues’ scripts. Do not hesitate to refer to the slides on the tab to the right of the IPython Shell. Unpacking lets you update a record in one step, but you don’t have to use it. You can add the key-value pair outside of the function call as well, by adding a few lines of code. Use any method you like, as long as the record is defined correctly.

Instructions 1/3

undefined XP
    1
    2
    3
  • Retrieve the products of the shop called Tesco.