A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-September/048964.html below:

[Python-Dev] python-dev Summary for 2004-08-16 through 2004-08-31 [draft]

[Python-Dev] python-dev Summary for 2004-08-16 through 2004-08-31 [draft] [Python-Dev] python-dev Summary for 2004-08-16 through 2004-08-31 [draft]Erik Heneryd erik at heneryd.com
Thu Sep 16 14:15:31 CEST 2004
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 
> safe_substitute 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:

1) substitute() and safe_substitute() are far too long names for such 
(probably) common/frequent operations.

2) 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... <wink>


Erik
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4