Created
July 20, 2022 00:32
-
-
Save kissgyorgy/b54bf78f199241e5cdc55abe9adc5118 to your computer and use it in GitHub Desktop.
Python: use prefix in a string.Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from string import Template | |
class EnvTemplate(Template): | |
"""Substitute variables regularly, but environment variables need "env." prefix, | |
and only with the braced syntax. | |
For example: ${env.HOME} works, but $env.HOME does nothing. | |
""" | |
braceidpattern = rf"(?:env\.)?{Template.idpattern}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment