Daniel Keast

Stuff about python

Python HTTP Server

Python has an http server in it’s standard library, and if you invoke the module directly from the command line it conveniently serves the local directory:

Python array columns

I wanted to access the columns in a 2D array in Python today. I found that it’s surprisingly simple to do. This is what I ended up with:

SQLite in Python

Python contains a SQLite client in it’s standard library. This is really useful for prototyping, and great for when a script grows into needing a little more data integrity. It’s really quite unexpected to be able to use something like this without any dependencies.

Jinja template as json

I found myself creating a mock web service for use in tests today. The idea was that during test setup I could post some json data that would then be returned during the test itself. Only a few parts of the response would change between tests, so I wanted to specify as little as possible to keep the tests descriptive.

Python DocTest

Python has a module called doctest in it’s standard library that will search for usage examples in your documentation and check that they work as shown. This means you can copy and paste snippets from the interactive shell, and ensure that they’re kept up to date.

Python Decimal

The Decimal class in the standard library is the way to avoid double precision errors in Python.