Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: miki725 on Jan 24th, 2013  |  syntax: Python  |  size: 0.42 KB  |  views: 29  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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.         ...