eykd/blueprint — Issue #2: Python 3 support
Author: 0ion9
Created: 2012-03-05 13:04:07+00:00
State: open

Supporting Python 3 looks pretty simple I'm currently using Blueprint under Python 3.

I achieved this by a) changing the definition of Divide in fields.py to support both py2 and py3,
and b) adding the parameter "use_2to3 = True" to the setup() call in setup.py (python2 ignores this parameter)

The change to Divide follows (hope it formats okay)

class Divide(_Operator):
"""When resolved, divides all the provided arguments and returns the result.
"""
try: # python 2
op = operator.div
except AttributeError: # python 3
op = operator.truediv
sym = '/'

AFAICS, that's all that was necessary to make it work for both Py2 and Py3 -- it really was dead easy.