def encode_short_string(pieces, value):
 encoded_value = as_bytes(value)
 length = len(encoded_value)
 if (length > 255):
  raise exceptions.ShortStringTooLong(encoded_value)
 pieces.append(struct.pack('B', length))
 pieces.append(encoded_value)
 return (1 + length)

def encode_short_string ( pieces , value ) : encoded_value = as_bytes ( value ) length = len ( encoded_value ) if ( length > 255 ) : raise exceptions . ShortStringTooLong ( encoded_value ) pieces . append ( struct . pack ( 'B' , length ) ) pieces . append ( encoded_value ) return ( 1 + length )
encode a string value as short string and append it to pieces list returning the size of the encoded value .