[Python-Dev] Re: Alternative Implementation for PEP292:SimpleString Substitutions (original) (raw)
Guido van Rossum gvanrossum at gmail.com
Wed Sep 8 17:08:07 CEST 2004
- Previous message: [Python-Dev] Re: Alternative Implementation for PEP292:SimpleString Substitutions
- Next message: [Python-Dev] Re: Alternative Implementation for PEP292:SimpleString Substitutions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Templates are meant to template text data, so Unicode is the right choice of baseclass from a design perspective.
Only in Python 3.0.
But even so, deriving from Unicode (or str) means the template class inherits a lot of unwanted operations. While I can see that concatenating templates probably works, slicing them or converting to lowercase etc. make no sense. IMO the standard Template class should implement a "narrow" interface, i.e. only the template expansion method (mod or something else), so it's clear that other compatible template classes shouldn't have to implement anything besides that. This avoids the issues we have with the mapping protocol: when does an object implement enough of the mapping API to be usable? That's currently ill-defined; sometimes, getitem is all you need, sometimes contains is required, sometimes keys, rarely setdefault.
-- --Guido van Rossum (home page: http://www.python.org/~guido/) Ask me about gmail.
- Previous message: [Python-Dev] Re: Alternative Implementation for PEP292:SimpleString Substitutions
- Next message: [Python-Dev] Re: Alternative Implementation for PEP292:SimpleString Substitutions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]