Skip to main content

NB: f2format is currently under reconstruction. It is highly recommended to directly install from the git repo or the pre-release distributions.


f2format

PyPI - Downloads PyPI - Version PyPI - Python Version

GitHub Actions - Status Codecov - Coverage Documentation Status

Write f-string in Python 3.6 flavour, and let f2format worry about back-port issues :beer:

  Since PEP 498, Python introduced f-string literals in version 3.6. Though released ever since December 23, 2016, Python 3.6 is still not widely used as expected. For those who are now used to f-strings, f2format provides an intelligent, yet imperfect, solution of a backport compiler by converting f-strings to str.format expressions, which guarantees you to always write f-strings in Python 3.6 flavour then compile for compatibility later.

  f2format is inspired and assisted by my good mate @gousaiyang. It functions by tokenising and parsing Python code into multiple abstract syntax trees (AST), through which it shall synthesise and extract expressions from f-string literals, and then reassemble the original string using str.format method. Besides conversion and format specification, f2format also considered and resolved string concatenation. Also, it always tries to maintain the original layout of source code, and accuracy of syntax.

Documentation

  See documentation for usage and more details.

Contribution

  Contributions are very welcome, especially fixing bugs and providing test cases. Note that code must remain valid and reasonable.

See Also

Metadata

Release files for bpc-f2format 0.8.7

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

Source distribution (sdist)

Source distribution for bpc-f2format 0.8.7
File Size Uploaded
bpc-f2format-0.8.7.tar.gz 16.8 kB Details

Release files / bpc-f2format-0.8.7.tar.gz

Download URL bpc-f2format-0.8.7.tar.gz
Size 16.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5c2affdf649b9c63709146fff42ad44a5f6b0a95e6c36c90740d373033b5111c
BLAKE2b-256 checksum
How to use checksums
5fac9998dd53a3c5b71f38dc2f85864bf818ceb801f92a6cb3f5c576a642ae14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release history Release notifications | RSS feed

This release

0.8.7 This release

1 release file

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