[Python-Dev] Alternative Implementation for PEP292:SimpleString Substitutions

Raymond Hettinger raymond.hettinger at verizon.net
Sat Sep 4 22:03:25 CEST 2004


> Other than .encode() are there any other methods of unicode objects
that
> return 8bit strings?

That misses the point.  Templates do not have to be unicode objects.
Template can be their own class rather than a subclass of unicode.  The
application does not demand that unicode be mentioned at all.

There seems to be a strong "just live with it" argument but no
advantages are offered other than it matching your personal approach to
text handling.  Why force it when you don't have to.  At least three of
your users (me, Aahz, and Fred) do not want unicode output when we have
str inputs. 


> Raymond is against the class-based implementation of PEP 292,

That choice is independent of the decision of whether to always coerce
to unicode.

Also, it more accurate to say that I think __mod__ operator is not
ideal.  If you want to stay with classes, Guido's __call__ syntax is
also fine.  It avoids the issues with %, makes it possible to have
keyword arguments, and lets you take advantage of polymorphism.

The % operator has several issues:
* it is mnemonic for %(name)s substitution not $ formatting.
* it is hard to find in the docs
* it is does not accept tuple/scalar arguments like % formatting
* its precedence is more appropriate for int.__mod__



Raymond



More information about the Python-Dev mailing list