Python and pickle

So you’ve got a complex object in Python, and you want to write it out to a file. For example, a dictionary of dictionaries. You can’t just write it out as you would plain-text.

This article from DataCamp gives a great explanation of the pickle module, which not only solves that problem; it also goes the other way, enabling you to un-pickle the saved data and use it in its original complex form.

This writing out of a data object is especially important for journalists, because you’ll want to be able to check and re-check your results. If you re-scrape data, the new dataset might not be the same as the one you used in the first place.

Note that there is also something faster (for very large datasets) called cPickle, but for Python 3 it has changed to _pickle (see this post).

pickle is a built-in module (see the docs).

SMS and Google Sheets with Python

Student presentations in my advanced class are usually very interesting, and we all learn about new libraries and tools.

This week, Ryan S. showed an app that a soon-to-be-married fellow built to manage invitations and RSVPs for his wedding (read about the app).

“Sending an SMS or MMS is one of the most common tasks performed on the Twilio Platform” (see example).

The Twilio API is quite a Swiss Army Knife for making phone calls and sending/receiving SMS messages! Read more about SMS and Twilio.

The Python-happy groom also used gspread, a Python client library for the Google Sheets API (docs and GitHub).

Just another demonstration that you can do anything with Python!

css.php