#NEWLINE# def str_to_bytes( value , encoding = 'utf-8' ) : #NEWLINE# #INDENT# if ( PY2 or ( value is None ) ) : #NEWLINE# #INDENT# return value #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( value , list ) : #NEWLINE# #INDENT# return [ str_to_bytes ( elem ) for elem in value ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return value . encode ( elem )