[Python-Dev] python-dev Summary for 2004-08-16 through 2004-08-31 [draft] (original) (raw)
Erik Heneryd erik at heneryd.com
Thu Sep 16 14:15:31 CEST 2004
- Previous message: [Python-Dev] python-dev Summary for 2004-08-16 through 2004-08-31 [draft]
- Next message: [Python-Dev] python-dev Summary for 2004-08-16 through 2004-08-31 [draft]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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. As expressed in the PEP 292: Method Names thread I (still) think that:
substitute() and safe_substitute() are far too long names for such (probably) common/frequent operations.
The design would be more flexible if done with the Template/SafeTemplate class approach. Less code duplication, easier to extend and it solves the long method name problem...
Didn't get that much (any) positive feedback though...
Erik
- Previous message: [Python-Dev] python-dev Summary for 2004-08-16 through 2004-08-31 [draft]
- Next message: [Python-Dev] python-dev Summary for 2004-08-16 through 2004-08-31 [draft]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]