connection.py: Make PEP8 friendly

Make code easier to read and more Python 3 compatible.