[Tutor] Fwd: Re: Logic help

Alan Gauld alan.gauld at yahoo.co.uk
Wed Aug 12 12:09:07 EDT 2020


Forwarding to list.

On 12/08/2020 15:33, Baptista Albert wrote:

> The data I get back has too much information about a specific country (
> area, longitude, latitude, borders etc), I only have to display few of
> the key value pairs like (name, population, currency and language). This
> was the reason I tried to use the json file 

But if you have key/value pairs why not just load them into a Python
dictionary and then use them from there? Only store the ones you care about.

Converting to a JSON file means converting to text, putting it in a file
then to read it back you have to scan the file to read it back. That's
super slow compared to just looking up a python dictionary.

The only value in a JSON file might be if the API returns its data in
the form of a JSON string, but even then parsing it into a dict makes
more sense than storing the file (c you only do it once).

> Do you need to see my code and the data? 

That's always helpful, but we should also see what documentation you
have on the API. Is it short or do you have a web link you can share?


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list