Python recipes.
One job per page. Each recipe shows the plain Python way first, then the shorter version with a Nitro tool. Every snippet is run before the site is published.
JSON and data
json.dumps in Python
Turn a dict into JSON text, and teach it about dates, decimals and sets.
Read ->JSONPath in Python
Pull values out of nested JSON, with or without a query language.
Read ->Parse JSON in Python
Turn JSON text into dicts and lists, and deal with text that is not JSON after all.
Read ->Pretty print JSON in Python
Indent it, sort it, and format a file without writing a script.
Read ->Working with JSON in Python
The four functions, the type table, and where each job is covered in detail.
Read ->Read a JSON file in Python
Open a JSON file, get a dict back, and handle the three ways it goes wrong.
Read ->Write JSON to a file in Python
Save a dict as JSON, change it later, and never leave a half-written file behind.
Read ->Images
Crop an image in Python
Get the four numbers in the box right, then crop to the centre, a square or any ratio.
Read ->Pillow in Python
Install Pillow, import it under its old name, and do the five jobs most scripts need.
Read ->Resize an image in Python
Shrink an image without squashing it, blurring it or making it bigger by accident.
Read ->