Skip to main content

PyPI version License: MIT Downloads LinkedIn

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

Repository

https://github.com/chigwell/py_template_expander

Metadata

Release files for py-template-expander 2025.9.131516

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-template-expander 2025.9.131516
File Size Uploaded Provenance Actions
py_template_expander-2025.9.131516.tar.gz 3.1 kB Without provenance Details for py_template_expander-2025.9.131516.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py-template-expander 2025.9.131516
File Interpreter ABI Platform Actions
py_template_expander-2025.9.131516-py3-none-any.whl Python 3 none any Details for py_template_expander-2025.9.131516-py3-none-any.whl

Total release size: 6.6 kB

Release files / py_template_expander-2025.9.131516.tar.gz

Download URL py_template_expander-2025.9.131516.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c6aa1f945e4a0b858a17c764636639310d6d9862576db5d5c6b0941c584a932c
BLAKE2b-256 checksum
How to use checksums
7c021afaf34e9b0852b682d24632ee70c12db2ec771a8e4edfa990e90f820b03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.11

Release files / py_template_expander-2025.9.131516-py3-none-any.whl

Download URL py_template_expander-2025.9.131516-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c622d73b0206ca62f401868f97e30127bf44996bc1e86d7d32134e7369e49b88
BLAKE2b-256 checksum
How to use checksums
efc72c22638657bb591b196d768a98239403eeff7da4ecd47ba4d677c7af81bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.11

Security for py-template-expander 2025.9.131516

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page