Protocol specifications written in Python

A session at EuroPython 2012

Wednesday 4th July, 2012

2:30pm to 3:30pm (CET)

Rapidly updating the requirements and implementation of a machine-to-machine communication protocol is hard in itself, and keeping a protocol specification and documentation up-to-date is always a burden, and sometimes becomes an impossibility.

At Visual Units, when this became a problem with the protocol between the embedded software and the fleet management server, we changed the approach and specified the protocol in Python. This allows us to use the specification directly when generating and parsing messages, as well as making it possible to generate protocol documentation, and source code for our Java (J2ME) client software. We implemented everything from scratch, and found it surprisingly easy to do without documentation and specifications external to The Code.

This talk will focus on lessons learned and pitfalls found during the implementation of this solution, with code examples from our current state of art as well as showcases of some of the mistakes we made and the types of magic used in different iterations - most notably metaclasses and the inspect and imp modules. It will follow the evolution from the first (quite horrible) attempts, to our current implementation. I will also discuss what has been gained by adopting this solution and the tradeoffs that we have made.

The intended audience is developers and designers who work with and design protocols, as well as developers with a general interest in code as specification. This is not a presentation of a framework for use in any application (although code is available), but an in-depth look at how far you can go with custom-built tools.

About the speaker

This person is speaking at this event.
Fredrik Håård

Developer et al., Softhouse Consulting

Fredrik Håård is a partner and specialist at Softhouse Consulting as well as co-founder and head developer at Visual Units, a Swedish company creating support tools for logistics. In addition to working as a developer, designer, and general troubleshooter, Fredrik holds courses and workshops in Python, Mercurial and Git and has given lectures in Python at Blekinge Institute of Technology. He has also held talks on minimalism in software development and on the benefits of Python in agile development. The common theme of his talks are minimalism and DIY as opposed to the proliferation of frameworks and off-the-shelf solutions.Fredrik believes that while process might be important, technology is important and interesting. A technophile and minimalist, he revels in solving problems in elegant ways while using minimal effort. He runs a Python blog at

Next session in Ravioli

3:30pm Big A Little i (Practical Artificial Intelligence in Python) by Tendayi Mawushe

Coverage of this session

Sign in to add slides, notes or videos to this session

EuroPython 2012

Italy Italy, Florence

2nd8th July 2012

Tell your friends!


Time 2:30pm3:30pm CET

Date Wed 4th July 2012


Ravioli, Grand Hotel Mediterraneo

Short URL

Official event site

View the schedule



See something wrong?

Report an issue with this session