My version, uses a re.sub, plus a function used as an object with a
one bit state:

from re import sub

def repl(o):
    repl.n = not repl.n
    return ":" if repl.n else ","
repl.n = False

print sub("_", repl, "hi_cat_bye_dog_foo_bar_red")

Bye,
bearophile
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to