Utilities for tstring
Project description
tstring-util
Utlities for Python 3.14 t-string.
Python 3.14 supports creating objects of type string.templatelib.Template by prefixing with a "t".
lazy rendering
render(string.templatelib.Template)->str
Provides ability to write t-string with function calls with deferred evaluation. Any callable marked !fn will consume as many following interpolations as its positional args, be invoked, and its stdout captured inline. Everything else is rendered in order.
Example
from tstring import render
def hello(name):
print(f"hello {name}")
def test_lazy():
who = 'bob'
flavor = 'spicy'
embedx = t'Call function {hello:!fn} {who} {flavor}'
who = 'jane'
r = render(embedx)
assert r == "Call function hello jane spicy"
Project details
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 tstring_util-0.2.tar.gz.
File metadata
- Download URL: tstring_util-0.2.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
313a87af318d236429bb788817727b641c14fae251392f6d63069a51f14ffb93
|
|
| MD5 |
5e60d5b3cf0800112f616829491192a4
|
|
| BLAKE2b-256 |
63bcdfc877685e4ecd97babf6b7284defa905c8356a7d6084e80b3a8e697a64b
|
File details
Details for the file tstring_util-0.2-py3-none-any.whl.
File metadata
- Download URL: tstring_util-0.2-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ffc122bb0dcc7ecd0800e8aefd88fbc6042a2188bb3c0ad9fe0b1992a6a001e
|
|
| MD5 |
361c1ad4f5c30e133eb485ccea5951c1
|
|
| BLAKE2b-256 |
609fc8402d0367a5682e150723991c14b7b7381fb5dff124447cb4fd26589434
|