On 17/01/2014 06:07, gmflanagan wrote:
On Sunday, January 12, 2014 3:08:31 PM UTC, Eric S. Johansson wrote:
As part of speech recognition accessibility tools that I'm building, I'm
using string.Template. In order to construct on-the-fly grammar, I need
to know all of the identifiers before the template is filled in. what is
the best way to do this?
Try this:
import string
cmplxstr="""a simple $string a longer $string a $last line ${another} one"""
def finditer(s):
for match in string.Template.pattern.finditer(s):
arg = match.group('braced') or match.group('named')
if arg:
yield arg
if __name__ == '__main__':
print set(finditer(cmplxstr))
Would you please read and action this
https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing the
double line spacing above, thanks.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
--
https://mail.python.org/mailman/listinfo/python-list