Update for Python 3 syntax

Updates the file for Python 3, so it runs with Sublime Text 3.

Not sure whether there is a better way than explicitly converting all_before and all_after to lists ...!? But that works.