[Python-Dev] Re: Alternative ImplementationforPEP292:SimpleString
Substitutions
Brett C.
bac at OCF.Berkeley.EDU
Sat Sep 11 19:07:29 CEST 2004
Martin v. Löwis wrote:
> Raymond Hettinger wrote:
>
>> [Brett]
>>
>>> I suspect stating exactly what a valid Python
>>> identifier contains as you did in parentheses above will be enough.
>>
>>
>>
>> Given the template, u'¿Puede volver $hoy o $mañana?', you think $ma is
>> an intended placeholder name and that ñ should be a delimiter just like
>> whitespace and punctuation?
>
>
> No, I think Brett (and apparently nearly everybody else) thinks that
> such a template will not be written over the course of the next five
> years, except for demonstration purposes. Instead, what will be written
> is u'¿Puede volver $today o $tomorrow?' because the template will be
> a translation of the original English template, and, during translation,
> placeholder names must not be changed (although I have difficulties
> imagining possible values for today or tomorrow so that this becomes
> meaningful).
>
Actually, that wasn't what I was thinking, but that also works. My
original thinking is that Template will throw a fit and that's fine
since they didn't follow the rules.
>> If end users always follow the rules, this will never come up. If they
>> don't, should there be error message or a silent failure?
>
>
> There is always a chance of a silent failure in SafeTemplates, even with
> this rule added - this is the purpose of SafeTemplates. With a Template,
> you will get a KeyError. In any case, the failure will not be completely
> silent, as the user will see $mañana show up in the output.
>
Right, my other reason for not thinking this is a big issue. If you use
SafeTemplate you will have to watch out for silent problems like this
anyway.
I just don't think it will be a big problem. And if people want the
support they will just use a pure Unicode Template subclass (perhaps we
should include that in the module?).
-Brett
More information about the Python-Dev
mailing list