SHARE
TWEET

Untitled

miki725 Jan 24th, 2013 37 Never
  1. def to_python(self, data):
  2.     # no logic, pass the logic to the wrapper
  3.     if isinstance(data, MyHexWrapper):
  4.         return data
  5.     else:
  6.         return MyHexWrapper(data)
  7.  
  8. class MyHexWrapper(object):
  9.     def __init__(self, data=None):
  10.         # deal with all different options here
  11.         t_data = type(data)
  12.         if t_data is foo:
  13.             pass
  14.         elif t_data is bar:
  15.             pass
  16.         ...
RAW Paste Data
Top