Created
March 15, 2024 13:17
-
-
Save jelmervdl/df4f54b400fbdfd82fa6f5243d23e97f to your computer and use it in GitHub Desktop.
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
def expand(expr:str): | |
if (match := re.search(r"\{(.+?)\}", expr)): | |
prefix = expr[:match.start()] | |
for val in match.group(1).split(','): | |
for suffix in expand(expr[match.end():]): | |
yield prefix + val + suffix | |
else: | |
yield expr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment