def parse_html_list(dictionary, prefix=''):
 ret = {}
 regex = re.compile(('^%s\\[([0-9]+)\\](.*)$' % re.escape(prefix)))
 for (field, value) in dictionary.items():
  match = regex.match(field)
  if (not match):
   continue
  (index, key) = match.groups()
  index = int(index)
  if (not key):
   ret[index] = value
  elif isinstance(ret.get(index), dict):
   ret[index][key] = value
  else:
   ret[index] = MultiValueDict({key: [value]})
 return [ret[item] for item in sorted(ret.keys())]

def parse_html_list ( dictionary , prefix = '' ) : ret = { } regex = re . compile ( ( '^%s\\[([0-9]+)\\](.*)$' % re . escape ( prefix ) ) ) for ( field , value ) in dictionary . items ( ) : match = regex . match ( field ) if ( not match ) : continue ( index , key ) = match . groups ( ) index = int ( index ) if ( not key ) : ret [ index ] = value elif isinstance ( ret . get ( index ) , dict ) : ret [ index ] [ key ] = value else : ret [ index ] = MultiValueDict ( { key : [ value ] } ) return [ ret [ item ] for item in sorted ( ret . keys ( ) ) ]
used to support list values in html forms .