home | tags | mulvany.net


Asilearn

Hunting for structure in nested JSON with python just got a whole lot easier

A very common python task that I find myself stumbling over repeatedly is trying to get the syntax right to address or retrieve a specific value to a key in a dented JSON document, in particular if that key is some way down the tree. I’ve just found the library https://github.com/mahmoud/glom which is written up really nicely here: https://sedimental.org/glom_restructured_data.html Before looking at this modele in detail I had thought that I could pass a reference to a key to glom without specifying its location fully in the structure of the input file, but after looking at this for a moment it became clear that this is not what it does, but rather is good at helping to remap nested data structures into new structures, and accessing the data you want via path like queries. ... (more)

Where should you host your Kubernetes solution?

I previously Kicked the tyres on kubernetes, with an example of how to deploy it onto Google’s infrastructure, but if you want to scale out and start dong some real work with this piece of infrastructure where should you go to have a hosted Kubernetes solution? I honestly don’t have an answer to that. The Kubernetes site provides a large list of providers. A friend of mine has been considering between https://stackpoint. ... (more)

python - running commands from within a directory

A neat python snippet for jumping into a directory, running a script, and jumping out again, found on Stackoverflow, provided by Brian Hunt. from subprocess import Popen, PIPE import os import sys class cd: """Context manager for changing the current working directory see https://stackoverflow.com/questions/431684/how-do-i-cd-in-python """ def __init__(self, newPath): self.newPath = os.path.expanduser(newPath) def __enter__(self): self.savedPath = os.getcwd() os.chdir(self.newPath) def __exit__(self, etype, value, traceback): os.chdir(self.savedPath) with cd("~/blog/partiallyattended"): title = new_post.title process = subprocess. ... (more)