[Python-Dev] Re: Re: Update PEP 292 (original) (raw)
Fredrik Lundh fredrik at pythonware.com
Wed Aug 11 21:16:58 CEST 2004
- Previous message: [Python-Dev] Re: Re: Re: Update PEP 292
- Next message: [Python-Dev] Update PEP 292
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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).
- Previous message: [Python-Dev] Re: Re: Re: Update PEP 292
- Next message: [Python-Dev] Update PEP 292
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]