Simple REST-ful (-ish) exposure of Python APIs

After having written code to expose APIs through RESTful web services a couple of times, I’ve decided to do it once more, only this time I won’t get paid, I won’t have deadlines, I’ll write it so I’ll never have to write it again, and I’ll make it available as open source. Problem is, I’m a lazy, lazy person, and have not been able to muster the energy to actually get writing, which leads me to this blog post - since I’ve not been updating the blog as I should either, I’ll kill two projects with one meeting and make the actual development process open as well, as a series of blog posts and a repository at BitBucket.

Sending non-valid names as arguments

I got a feature request on hgapi the other day, pointing out that it was not possible to filter the Mercurial log using the API, since there is no dedicated way to do it and the fallback method - sending keyword arguments that will be passed to the command line - does not work. The signature of the method in question is def hg_log(self, identifier=None, limit=None, template=None, branch=None, **kwargs): with kwargs accepting any keyword arguments and passing them to the command line.

See me on an island!

I’ve really neglected to update the blog lately, but that’s at least in part because I’ve been busy doing preparations for talks - so you could /see/ me instead of read my blog! I’ll be speaking both at PyCon UK and PyCon Ireland, so if you’re going to either come chat with me! And, you know, maybe see my talks… Also, I do have a proper blog post with actual content a-brewing, and I promise it will be done Real Soon Now ™.

You should send a presentation proposal to PyCon

Next year, in March, I will be at PyCon. It will be the third time I attend PyCon - ever since I attended my first, not going has not really been an option. There are lots of good things about PyCon - meeting interesting people, seeing San Francisco, beating off recruiters with a stick, hanging out in the hotel bar and chill in the evenings - but the best part is that the talks are so many, and so good.

Using the AST to hack constants into Python

During EuroPython 2012, after my training and talks, I really needed to do some coding, so I started hacking on a ‘practical’ application of the AST - making (some) constants faster than local variables, instead of slower by inlining them on import. To do this, I use a custom importer on meta_path to intercept the import, and find any assignments look like constants - that is, any module-level variable in ALL_CAPS that is a simple string or a number.

EuroPython impressions

I had a blast at Europython - I made new friends, went to a couple of talks that gave me some ideas for the future, and my own talks seemed to go down well. All in all, the EP2012 organization was great, the food was way beyond ‘normal’ conference fare, and the venue was good - although finding a place to sit down during lunch was hard. I would have liked some kind of feedback mechanism in place for the talks - had I known there would be none I’d have arranged one for my own talks and especially the training session I held.

You deserve practice

I enjoyed The Clean Coder by Uncle Bob, and would recommend it to any serious developer. I agree with almost everything in it, but there is one jarring exception - I disagree strongly with his view that because it’s your own responsibility to practice, you should not do it on paid time. Under the headline “Practice Ethics”, he states: “Professional programmers practice on their own time. It is not your employer’s job to help you keep your skills sharp for you [.

Version 1.2.0 of hgapi released

hgapi is a pure-Python API for Mercurial, which uses the command-line interface for maximum compatibility. It is tested for Python 2.7 and 3.2.

Version 1.2.0 fixes a few bugs, and allows iterating over a repository as well as using slices ( i.e. repo[0:'tip']) to get a set of changesets. API documentation is also slightly improved.

Special thanks to Nick Jennings and Adam Gomaa who contributed patches.

Protocol specifications written in Python

This is a writeup of a talk I did recently at Software Passion Summit in Gothenburg, Sweden. For more background info, see the post I did prior to the conference. Writing a specification in a full-blown programming language like Python has upsides and downsides. On the downside, Python is not designed as a declarative language, so any attempt to make it declarative (apart from just listing native data types) will require some kind of customization and/or tooling to work.

PyCon 2012 - the other stuff

I have tried to do a full writeup of my PyCon experience this year, and failed miserably, so this is what I’ll do: This post will focus only on the conference experience - lessons learned, sessions attended, and projects discovered will have their own posts; this is the other stuff. So what about the conference as a whole? It was, just like Atlanta last year, an overwhelmingly positive experience. This was the first time I volunteered, and I really felt that that was a given win - from getting to have a say in the program by joining the program committee, through doing a session as a session runner and getting to see all the work that goes on behind the scenes, to responding to a just-in-time tweet to join the swag-packing party.