[Python-Dev] Re: Alternative Implementation for PEP 292:Simple String Substitutions (original) (raw)

Moore, Paul Paul.Moore at atosorigin.com
Fri Sep 3 17:49:59 CEST 2004


From: Barry Warsaw

Attached is a demo using the 2.4a3 implementation of string.Template. Note that the only change in the Template subclass is the pattern, and there, it's just that the 'named' and 'braced' groups got a '.' in the second character class.

Ah, I follow. The lookup logic is in the mapping class rather than in the template.

Would it be useful to factor out the "identifier syntax" bit of the pattern? The "escaped" and "bogus" groups are less likely to need changing than what constitutes an identifier.

Hmm, you'd have to get fancy then, as the "obvious" approach is a class attribute

id = "[_a-z][_a-z0-9]*"

but then computing pattern while keeping it as a class attribute is harder than I can work out right now.

Forget it - let's keep it simple until someone shows a real need.

Thanks for the sample, Paul.


This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the Internet, the Atos Origin group liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted.




More information about the Python-Dev mailing list