Hello, Is there a better, *built-in* alternative for the code below? The recursion works, but it feels like reinventing the wheel.
import string def translate(template, *args): """Recursively $-substitute <template> using <args> as a replacement""" syntax = string.Template(template).substitute(*args) if "$" in syntax: return translate(syntax, *args) return syntax template = """\ Monty $surname $more """ more = """\ The quest for the holy $grail """ surname="Python" grail="Grail" print translate(template, locals()) Thank you! Regards, Albert-Jan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
