rexpr
A small library that uses Python 3.14's new templates (t-strings) to smoothly implement a way to turn an expression into its source code string dynamically.
Advantages
This solution brings multiple advantages:
- Laziness: If the expression should does not need to be evaluated (only the source code string is desired), it won't be.
- Fast: Only very few basic string checks and modifications are performed.
- Builtin support by type checkers and linters: As long as a type checker / linter supports templates, the correct return value (if evaluated), the correctness of the expression and the correct type of the interpolation can be verified. As of writing this (Python 3.14rc2), generic support for templates and interpolations has been added, but is not yet supported by typeshed and type checkers.
- Single point of truth: By having the possibility to also evaluate an expression in the same function call, there is no need to duplicate an expression to get both its evaluated value and its source code string.
References
This module is an implementation of the ideas and solutions proposed by my topic.
Metadata
Release files for rexpr 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rexpr-1.0.0.tar.gz | 5.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rexpr-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.8 kB
Release files / rexpr-1.0.0.tar.gz
| Download URL | rexpr-1.0.0.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d20032cb2bb516cb70a4da3e170e9414485c42861b425a4dce3c8a106eb8afa6
|
|
BLAKE2b-256 checksum How to use checksums |
2b68305b7b21dd56e1a2bc1c56f624bf07083550b75ce31a10452f682e884801
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0rc2
|
Release files / rexpr-1.0.0-py3-none-any.whl
| Download URL | rexpr-1.0.0-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9aa692db0aa48819f43751ceda3192e2c7dbd6c4c62f3d179975e6479220db88
|
|
BLAKE2b-256 checksum How to use checksums |
fd5ccda7601914ac5930ff5b9203c537ad553344307a9486a82dea959d4b4a1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0rc2
|