Python – Add data to external files and get JSON data from files

initially, the idea of the article was to write four lines of code, doing the following 2 tasks:

    • uploading data to a given file
    • getting JSON data from file and using it in an application


However, as soon as I started, I considered that I would probably need a little more lines to generate the data in a better way. Thus, I decided to build two classes – class FootballPlayer and class FootballTeam. The FootballTeam is consisted of players, thus I have added the functions  add_to_team(), change_team_list(), show_team(). They are dealing with the dictionary _teamList, which is generated on initialization of the FootballTeam class. The dictionary _teamList is the one, to be uploaded to a file and later downloaded. All of the progress is printed on almost every step, like this:



So, pretty much that is all, folks! The code is available in GitHub and below:

Enjoy it! 🙂

Tagged with: , , , , ,