How to print the string template pattern in Python

1 Answer

0 votes
import string     

t = string.Template('$s')  

print(t.pattern.pattern)



'''
run

    \$(?:
      (?P<escaped>\$) |   # Escape sequence of two delimiters
      (?P<named>(?-i:[_a-zA-Z][_a-zA-Z0-9]*))      |   # delimiter and a Python identifier
      {(?P<braced>(?-i:[_a-zA-Z][_a-zA-Z0-9]*))}   |   # delimiter and a braced identifier
      (?P<invalid>)              # Other ill-formed delimiter exprs
    )

'''

 



answered Apr 26, 2019 by avibootz

Related questions

...