gargonx wrote:
yes the items in std are always single to single, and ext single to
double. basicly the ext are refernce to the std itmes. the second
character in ext is a number depending on how far it is from the item
in std. this is just a simple encoding program.

If your keys are always single characters (as this description seems to suggest) then the last code I posted should do what you want. Repeated here for your enjoyment:


# merge mappings:
# std has highest precedence, then ext, then punc
replacements = {}
replacements.update(punc)
replacements.update(ext)
replacements.update(std)

# define encoding procedure
def proc(text):
    # replace each character with its replacement
    # or leave character unchanged if not in the mapping
    return ''.join([replacements.get(c, c) for c in text])

Steve
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to