code: def assign(self, V, py):
          
          if isinstance(py, (bytes, unicode)):
              for i,C in enumerate(V['value.choices'] or self._choices):
                  if py==C:
                      V['value.index'] = i
                      return
  
          # attempt to parse as integer
          V['value.index'] = py
docs: Store python value in Value