Barry Warsaw wrote: > I specifically designed it so that you could subclass from template, so as to > accept the extended placeholder syntax (i.e. dots), and then implement a > mapping-like class to do the lookups in any namespace you want. on the other hand, to do that, you need to replace the pattern, and make sure that you have the same number of groups, with the same meaning. it's doable, but it's rather fragile. two suggestions: - refactor the RE, and use lastindex to extract the name (see the link I posted earlier). This would let users add any number of patterns, without having to rewrite the __mod__ method. And indexing by lastindex should be faster than tuple unpacking, too. - Consider changing the ${} to accept arbitrary patterns, instead of just Python-style identifiers. \${([^}]+)} should do the trick. - Consider using character classes instead of re.IGNORECASE (easier to read, and IIRC, slightly faster). </F>
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