A simple Python library for expanding template strings with optional groups and character sets.
Project description
py_template_expander
A Python package that expands template strings with various placeholders including optional groups, alternatives, and character sets.
Installation
To install py_template_expander, use pip:
pip install py_template_expander
Usage
The expand function takes a template string and yields all possible expanded strings.
Here's a simple example:
from py_template_expander import expand
template1 = "Hello (world|there)!"
print("Expanding: ", template1)
for expansion in expand(template1):
print(expansion)
# Expected output:
# Expanding: Hello (world|there)!
# Hello world!
# Hello there!
template2 = "The quick [abc] fox."
print("\nExpanding: ", template2)
for expansion in expand(template2):
print(expansion)
# Expected output:
# Expanding: The quick [abc] fox.
# The quick a fox.
# The quick b fox.
# The quick c fox.
template3 = "Optional: (item1|item2) and (optional|)"
print("\nExpanding: ", template3)
for expansion in expand(template3):
print(expansion)
# Expected output:
# Expanding: Optional: (item1|item2) and (optional|)
# Optional: item1 and optional
# Optional: item1 and
# Optional: item2 and optional
# Optional: item2 and
# Optional: and optional
# Optional: and
Features
- Optional Groups: Use
(pattern)for parts that may or may not appear. - Alternatives: Use
|within parentheses to specify choices, e.g.,(A|B). - Character Sets: Use
[abc]to match any single character within the brackets.
Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
License
py_template_expander is licensed under the MIT License.
Author
Eugene Evstafev
- LinkedIn: eugene-evstafev-716669181
- Email: hi@eugene.plus
Repository
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_template_expander-2025.9.131516.tar.gz.
File metadata
- Download URL: py_template_expander-2025.9.131516.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6aa1f945e4a0b858a17c764636639310d6d9862576db5d5c6b0941c584a932c
|
|
| MD5 |
7107e5f7d9fac6f8f8b65e6d3cf4fc90
|
|
| BLAKE2b-256 |
7c021afaf34e9b0852b682d24632ee70c12db2ec771a8e4edfa990e90f820b03
|
File details
Details for the file py_template_expander-2025.9.131516-py3-none-any.whl.
File metadata
- Download URL: py_template_expander-2025.9.131516-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c622d73b0206ca62f401868f97e30127bf44996bc1e86d7d32134e7369e49b88
|
|
| MD5 |
a62673105ea5513a13e63217e4f2e292
|
|
| BLAKE2b-256 |
efc72c22638657bb591b196d768a98239403eeff7da4ecd47ba4d677c7af81bb
|