Skip to main content

future-tstrings

A backport of tstrings to python<3.14

Also serves as a backport of full-syntax fstrings (PEP701-style) to python <3.12.

Does nothing on 3.14 or higher.

Requires python >= 3.8

Installation

pip install future-tstrings

Usage

Include the following magic line at the top of the file (before regular imports)

# future-tstrings

And then write python 3.14 tstring and fstring code as usual!

- example.py

from string.templatelib import Template  # or, future_tstrings.templatelib

thing = "world"
template: Template = t"hello {thing}"

print(repr(template))
# t"hello {'world'}"

assert template.strings[0] == "hello "
assert template.interpolations[0].value == "world"
$ python -m example
t"hello {'world'}"

Showing compiled source

future-tstrings also includes a cli to show transformed source.

$ future-tstrings example.py

Integrating with template processing tools

Libraries that consume template strings (html parsers, etc) do not need to do anything extra to support future-tstrings, except:

They should NOT disable this behavior on python<3.14. To implicitly support future-tstrings without listing it as a dependency, use the following:

try:
    from string.templatelib import Template
except ImportError:
    class Template:
        pass

How does this work?

future-tstrings has two parts:

  1. An importer which transpiles t-strings and f-strings to code understood by older versions of python

  2. A .pth file which registers the importer on interpreter startup.

Alternative python environments

In environments (such as aws lambda) where packages are not installed via pip, the .pth magic will not work, so you'll need to manually initialize future-tstrings in a wrapper python module. For instance:

from future_tstrings import install

install()

from actual_main import main

if __name__ == '__main__':
    main()

Additionally, for zipped or frozen packages, the importer will not work. In such environments, you will need to use the future-tstrings command-line compiler before the code is zipped, frozen, etc.

Metadata

Release files for future-tstrings 1.0.1

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

Source distribution (sdist)

Source distribution for future-tstrings 1.0.1
File Size Uploaded Provenance Actions
future_tstrings-1.0.1.tar.gz 36.2 kB With provenance Details for future_tstrings-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for future-tstrings 1.0.1
File Interpreter ABI Platform Actions
future_tstrings-1.0.1-py3-none-any.whl Python 3 none any Details for future_tstrings-1.0.1-py3-none-any.whl

Total release size: 61.9 kB

Release files / future_tstrings-1.0.1.tar.gz

Download URL future_tstrings-1.0.1.tar.gz
Size 36.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9dd8bf64f6d00a0a503831f720f0dec2876524707a0f8eca5c8a95cc2630d21a
BLAKE2b-256 checksum
How to use checksums
1361ac517514abe2fd5ff7f9b66d9469bcaeb6d831f2f7dd9f4530ced5737618
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 18, 2026.

Transparency log

Release files / future_tstrings-1.0.1-py3-none-any.whl

Download URL future_tstrings-1.0.1-py3-none-any.whl
Size 25.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2bc55c331e42ba72896a25a24a891aca30267cd5ac0f57e960b53db318780a8e
BLAKE2b-256 checksum
How to use checksums
0c27a28ec6e1ad79b17356acfa9e5955a2e7d0f5df6d7e65762e524c889f093f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 18, 2026.

Transparency log

Security for future-tstrings 1.0.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for future_tstrings-1.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 18, 2026.

Transparency log

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.

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