Make code Python 3.x compatible