[Python-Dev] python-dev Summary for 2004-08-16 through 2004-08-31 [draft] (original) (raw)

Brett C. bac at OCF.Berkeley.EDU
Thu Sep 16 18:41:15 CEST 2004


Erik Heneryd wrote:

Brett C. wrote:

The second issue was other the design of the API. Originally Template was a class that overrode mod to make it work like string interpolation works now for str and unicode. But then some people felt a class was too heavy-handed if there was no way to change the way Template worked through a subclass. This obviously led to a desire for functions to do the work for both Template and SafeTemplate (similar class to Template that left in substitution points if they didn't match any values in the dict passed in).

In the end the class design was kept thanks to Tim Peters and metaclasses. Tim came up with a neat way to have the regex be generated at class creation time through a metaclass and thus allow subclasses to change how Template matched substitution points and such, all without a performance hit at instance creation time. Use of mod and the SafeTemplate class were removed and Template grew substitute and safesubstitute methods. Everyone at this point seems happy with the design. Well, not everyone.

OK, it now says "practically everyone". =)

-Brett



More information about the Python-Dev mailing list