On Mon, 2006-04-03 at 15:23 -0500, Ian Bicking wrote: > This is all wandering off-topic, except that all these cases make me > think that different kinds of wrapping are very useful. For instance, > if you want to make sure everything is quoted before being inserted: > > class EscapingWrapper: > def __init__(self, d): > self.d = d > def __getitem__(self, item): > return cgi.escape(str(self.d[item]), 1) > > Or if you want expressions: > > class EvalingWrapper: > def __init__(self, d): > self.d = d > def __getitem__(self, item): > return eval(item, d) > > Then you do: > > string.Template(pattern).substitute(EscapingWrapper(EvalingWrapper(locals()))
I like this. I'd probably not utilize EvalingWrapper, just because I'd really want to keep translatable strings really really simple. I think most translators can grok simple $-substitutions because they've seen those in many other languages. -Barry
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com