ported to Python 3.4.1 (compatibility tested for Python 2.7.3)