skillfed

future-fstrings

A backport of fstrings to python<3.6

future-fstrings v1.2.0 749.7K downloads/30d#5,160 on PyPI389
Permissive license MIT Abandoned released

What it is and what it does

future-fstrings is a codec-based backport that allows you to write Python 3.6+ f-string syntax and run it on Python 2.7 and Python 3.4–3.5. You add a special encoding cookie to the top of your file, and the package intercepts the source at import time, rewriting f-strings into equivalent `.format()` calls before the Python interpreter sees them. This works by registering a custom UTF-8 codec on startup that uses tokenize-rt to perform the transformation.

The package also provides a command-line tool (`future-fstrings-show`) to pre-transform source files, useful for distributing code to platforms like micropython that don't support f-strings at all. However, the project is archived and no longer maintained, so it will not adapt to future Python changes or receive security updates.

Use it for:

  • Maintain a single f-string codebase that runs on Python 2.7 and early Python 3 versions without duplicating syntax.
  • Pre-transform source code before deploying to micropython or other embedded platforms that lack f-string support.
  • Gradually migrate legacy Python 2.7 codebases to modern f-string syntax while maintaining backward compatibility during transition.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Enables f-string syntax in Python versions before 3.6 by transparently rewriting f-strings to `.format()` calls at import time via a custom codec.

No. The package is abandoned (last updated 2022-01-15) and targets Python versions that are themselves end-of-life. If you need f-strings on older Python, this was useful historically, but new projects should target Python 3.6+. Existing projects still on unsupported Python versions should prioritize upgrading rather than relying on unmaintained backports.

Install

future-fstrings on PyPI

pip

pip install future-fstrings

uv

uv add future-fstrings

poetry

poetry add future-fstrings

Installing future-fstrings

Before you install

Installation is straightforward with low friction, but the package is abandoned as of 2022-01-15 with no active maintenance. It was last released on 2019-06-16, so it will not receive updates for new Python versions or security issues.

License in practice

MIT license permits free use, modification, and distribution with minimal restrictions, making it safe to adopt from a licensing perspective.

Quickstart

# Install
pip install future-fstrings

# At the top of your .py file, add:
# -*- coding: future_fstrings -*-

# Then write f-strings normally:
thing = 'world'
print(f'hello {thing}')

# Run on Python 2.7 or 3.4–3.5; the codec rewrites it to:
# print('hello {}'.format((thing)))

Requires Python 2.7 or 3.4–3.5 to run with the codec active; Python 3.6+ natively supports f-strings and does not need this package. The encoding cookie must be the first or second line of the file.

Verify before relying

  • Whether the codec approach remains reliable on modern Python interpreters beyond the versions it was tested against.
  • Compatibility with third-party tools that parse or analyze Python source code (linters, type checkers, etc.).
  • Whether Python 2.7 and Python 3.4–3.5 remain viable targets for new projects using this package.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*)
Install friction low — pure-Python wheel
Runtime dependencies 1 — tokenize-rt
Maintenance abandoned — 2,616 days since the last release
Last repo commit (repository archived)
First released
Downloads 749,735/month — #5,160 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: future_fstrings-1.2.0-py2.py3-none-any.whl

License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy

Tags

f-string backport python 2.7fstring support older pythonpython 2 f-stringsformat string compatibilitymicropython f-string rewrite
legacy-pythonsyntax-transformationcodec

More Software Development packages