[Python-Dev] Re: Alternative Implementation for PEP 292: Simple String Substitutions

Guido van Rossum gvanrossum at gmail.com
Sun Aug 29 19:37:30 CEST 2004


> As a test case, how would I implement the case that has come up here
> recently, of supporting $obj.attr substitutions, in each of the two
> implementations? It would be interesting to see the relative
> simplicity. I'm assuming that the function-based case would require
> effectively a cut & paste reimplementation.
> 
> [FX: Dives into source code...]
> The Template class is pretty trivial, but it doesn't seem to be
> designed for extension. Thus, the above test case would *still* need
> pretty much a rewrite. However, if the Template class was rewritten
> with overriding in mind, it probably could make things easier:

Subclassing is only one possibility. With the templating version, you
could also write another class that implements the same interface --
very Pythonic. If Raymond's function approach were chosen, you're
stuck with what that function can and can't do.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list