[Python-Dev] Alternative Implementation for PEP 292:SimpleString Substitutions

M.-A. Lemburg mal at egenix.com
Fri Sep 3 22:37:54 CEST 2004


Raymond Hettinger wrote:
>>>By not inheriting from unicode, the bug can be fixed while retaining a
>>>class implementation (see sandbox\curry292.py for an example).
>>>
>>>But, be clear, it *is* a bug.
>>>
>>>If all the inputs are strings, Unicode should not magically appear. See
>>>all the other string methods as an example.
>>
>>But the Template classes aren't string methods, so I don't think the
>>analogy is quite right.  Because the template string itself is by
>>definition a Unicode, it actually makes more sense that everything its
>>mod operator returns is also a Unicode.  So I still don't think it's a
>>bug.
> 
> 
> Templates are not Unicode by definition.  That is an arbitrary
> implementation quirk and a design flaw.
> 
> The '%(key)s' forms do not behave this way.   They return str unless one
> of the inputs are unicode.
> 
> People should be able to use Python and not have to deal with Unicode
> unless that is an intentional part of their design.
> 
> Unless there is some compelling advantage to going beyond the PEP and
> changing all the rules, it is a bug.

I think Barry needs some backup here.

First, please be aware that normal use of Templates is for formatting
*text* data. Second, it is good design and good practice to store text
data in Unicode objects, because that's what they were designed for,
while string objects have always been an abstract container for storing
bytes with varying meanings and interpretations. The latter is
a design flaw that needs to get fixed, not the choice of Unicode
as Template base class.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Sep 03 2004)
 >>> Python/Zope Consulting and Support ...        http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::


More information about the Python-Dev mailing list