(key)
return key
Takes a string and returns a list of bytestrings, suitable for use as
    a key or path in an FSA/FST graph.
Takes a string and returns a list of bytestrings, suitable for use as
    a key or path in an FSA/FST graph.
Takes a string and returns a list of bytestrings suitable for use as a key or path in an FSA / FST graph .
def to_labels(key):
    """Takes a string and returns a list of bytestrings, suitable for use as
    a key or path in an FSA/FST graph.
    """

    # Convert to tuples of bytestrings (must be tuples so they can be hashed)
    keytype = type(key)

    # I hate the Python 3 bytes object so friggin much
    if keytype is tuple or keytype is list:
        if not all(isinstance(e, bytes_type) for e in key):
            raise TypeError("%r contains a non-bytestring" % key)
        if keytype is list:
            key = tuple(key)
    elif isinstance(key, bytes_type):
        key = tuple(key[i:i + 1] for i in xrange(len(key)))
    elif isinstance(key, text_type):
        key = tuple(utf8encode(key[i:i + 1])[0] for i in xrange(len(key)))
    else:
        raise TypeError("Don't know how to convert %r" % key)
    return key
def to_labels ( key ) : # Convert to tuples of bytestrings (must be tuples so they can be hashed) keytype = type ( key ) # I hate the Python 3 bytes object so friggin much if keytype is tuple or keytype is list : if not all ( isinstance ( e , bytes_type ) for e in key ) : raise TypeError ( "%r contains a non-bytestring" % key ) if keytype is list : key = tuple ( key ) elif isinstance ( key , bytes_type ) : key = tuple ( key [ i : i + 1 ] for i in xrange ( len ( key ) ) ) elif isinstance ( key , text_type ) : key = tuple ( utf8encode ( key [ i : i + 1 ] ) [ 0 ] for i in xrange ( len ( key ) ) ) else : raise TypeError ( "Don't know how to convert %r" % key ) return key