def to_binary_string(obj, encoding=None):
 if PY2:
  if (encoding is None):
   return str(obj)
  else:
   return obj.encode(encoding)
 else:
  return bytes(obj, ('utf-8' if (encoding is None) else encoding))

def to_binary_string ( obj , encoding = None ) : if PY2 : if ( encoding is None ) : return str ( obj ) else : return obj . encode ( encoding ) else : return bytes ( obj , ( 'utf-8' if ( encoding is None ) else encoding ) )
convert obj to binary string .