Latest python posts

Syntactic Sugar vs Maintainability

I've just given a talk at PyCon UK, called Syntactic Sugar vs Maintainability, looking at balancing helping your users at the cost of your sanity.

The synopsis was:

Is it ever worth committing coding sins for the greater good? We'll look at techniques which can make your code easier to use at the cost of being harder to maintain, and when the effort is worth the reward.

There are plenty of ways in which you can use and abuse the power of python to make your library code easier for your users to work with. I'm going ...

Read full post

Mara - a Python network service framework

I've released a new version of Mara, my network service framework written in Python. It aims to make it easy to build TCP/IP services, such as echo servers, flash policy servers, chatrooms, talkers and MUDs.

It's event-based; that is to say you write event listener functions which you bind to events that your service raises - like Connect, Receive or Disconnect.

Mara is on pypi, so you can pip install mara, then start writing your service. An echo server in Mara looks like this:

from mara import Service
service = Service()

@service.listen(mara.events.Receive)
def receive(event ...

Read full post

Introducing Tagulous

Tagulous is a tagging library for Django which is based on ManyToManyField and ForeignKey relationships. I've been developing and using it internally for several years, and have recently tidied it up for release; it supports Django 1.4 to 1.9a, on Python 2.7 to 3.5.

It started with a simple enough idea - rather than use generic relations like other tagging libraries, use a subclass of ManyToManyField which supports assignment using tag strings, to allow things like this:

class Person(models.Model):
  name = models.CharField(max_length=255)
  skills = TagField()

person = Person.objects.create(name='Bob', skills='run ...

Read full post