
Barry wrote:
Not true. I had a very specific reason for making Templates subclasses of unicode. Read the Internationalization section of the PEP.
this section? The implementation supports internationalization magic by keeping the original string value intact. In fact, all the work of the special substitution rules are implemented by overriding the __mod__() operator. However the string value of a Template (or SafeTemplate) is the string that was passed to its constructor. This approach allows a gettext-based internationalized program to use the Template instance as a lookup into the catalog; in fact gettext doesn't care that the catalog key is a Template. Because the value of the Template is the original $-string, translators also never need to use %-strings. The right thing will happen at run-time. I don't follow: if you're passing a template to gettext, do you really get a template back? if that's really the case, is being able to write "_(Template(x))" really that much of an advantage over writing "Template(_(x))" ? if that's really the case, you can still get the same effect from a template factory function, or a trivial modification of gettext. </F>