Month: May 2013

Running iPython cleanly inside a virtualenv

If you run ipython directly on the commandline without having it installed inside the virtualenv you are working on you may get some awkward behaviour since iPython will be running a mix of environments (system wide + virtualenv) … normally you would see an warning as follows WARNING: Attempting to work in a virtualenv. If…

continue reading
No Comments

Parse JSON into ordered data-structure (in python)

In many cases it is essential (or at the least nicer) to preserve key order from a parsed JSON document, here is how to do it in python (using the std lib json module and OrderedDict available in python 2.7+) from collections import OrderedDict import json r = json.load(open(‘file.json’), object_pairs_hook=OrderedDict) print json.dumps(r, indent=2)

continue reading
No Comments