def to_python(self, data):
# no logic, pass the logic to the wrapper
if isinstance(data, MyHexWrapper):
return data
else:
return MyHexWrapper(data)
class MyHexWrapper(object):
def __init__(self, data=None):
# deal with all different options here
t_data = type(data)
if t_data is foo:
pass
elif t_data is bar:
pass
...