def tob(data, enc='utf8'):
    """ Convert anything to bytes """
    return data.encode(enc) if isinstance(data, six.text_type) else bytes(data)
def tob ( data , enc = 'utf8' ) : return data . encode ( enc ) if isinstance ( data , six . text_type ) else bytes ( data )
Convert anything to bytes