(s)
return s.encode('utf-8')
Converts a string argument to a byte string.

    If the argument is already a byte string, it is returned unchanged.
    Otherwise it must be a unicode string and is encoded as utf8.
Converts a string argument to a byte string.
Converts a string argument to a byte string .
def to_basestring(s):
    """Converts a string argument to a byte string.

    If the argument is already a byte string, it is returned unchanged.
    Otherwise it must be a unicode string and is encoded as utf8.
    """
    if isinstance(s, bytes):
        return s

    return s.encode('utf-8')
def to_basestring ( s ) : if isinstance ( s , bytes ) : return s return s . encode ( 'utf-8' )