def dynamize_value(val):
 dynamodb_type = get_dynamodb_type(val)
 if (dynamodb_type == 'N'):
  val = {dynamodb_type: serialize_num(val)}
 elif (dynamodb_type == 'S'):
  val = {dynamodb_type: val}
 elif (dynamodb_type == 'NS'):
  val = {dynamodb_type: list(map(serialize_num, val))}
 elif (dynamodb_type == 'SS'):
  val = {dynamodb_type: [n for n in val]}
 elif (dynamodb_type == 'B'):
  if isinstance(val, bytes):
   val = Binary(val)
  val = {dynamodb_type: val.encode()}
 elif (dynamodb_type == 'BS'):
  val = {dynamodb_type: [n.encode() for n in val]}
 return val

def dynamize_value ( val ) : dynamodb_type = get_dynamodb_type ( val ) if ( dynamodb_type == 'N' ) : val = { dynamodb_type : serialize_num ( val ) } elif ( dynamodb_type == 'S' ) : val = { dynamodb_type : val } elif ( dynamodb_type == 'NS' ) : val = { dynamodb_type : list ( map ( serialize_num , val ) ) } elif ( dynamodb_type == 'SS' ) : val = { dynamodb_type : [ n for n in val ] } elif ( dynamodb_type == 'B' ) : if isinstance ( val , bytes ) : val = Binary ( val ) val = { dynamodb_type : val . encode ( ) } elif ( dynamodb_type == 'BS' ) : val = { dynamodb_type : [ n . encode ( ) for n in val ] } return val
take a scalar python value and return a dict consisting of the amazon dynamodb type specification and the value that needs to be sent to amazon dynamodb .