Python implementation of HQ9+