effit
Custom augmented-assignment syntax for Python. Write
x scale= 2instead ofx = scale(x, 2).
What is effit?
effit introduces a custom syntax extension to Python: the function-assignment operator.
Instead of writing:
x = scale(x, 2)
my_list = append_items(my_list, [4, 5])
data = merge(data, {"b": 2})
You can write:
x scale= 2
my_list append_items= [4, 5]
data merge= {"b": 2}
The general pattern is:
<target> <function_name>= <arguments>
which transpiles to:
<target> = <function_name>(<target>, <arguments>)
Installation
pip install effit
For development:
git clone https://github.com/yoelAshkenazi/effit.git
cd effit
pip install -e ".[dev]"
Quick Start
Option 1: Using .eff files (recommended)
- Activate the hook in your entry point (e.g.,
main.py):
import effit
effit.activate()
# Now you can import .eff files as regular modules
import my_module # will find and transpile my_module.eff
- Write your
.efffile (my_module.eff):
def scale(x, factor):
return x * factor
def add(x, y):
return x + y
x = 10
x scale= 2 # x is now 20
x add= 5 # x is now 25
print(x) # prints 25
Option 2: Intercept .py files too
import effit
effit.activate(transpile_py=True)
# Now ALL .py imports are transpiled (adds slight overhead)
Option 3: Transpile and execute a string directly
import effit
source = """
def scale(x, factor):
return x * factor
x = 10
x scale= 2
"""
ns = effit.run_string(source)
print(ns['x']) # 20
Option 4: Just transpile (no execution)
import effit
code = "x scale= 2"
print(effit.transpile_line(code))
# Output: x = scale(x, 2)
source = """
x = 10
x scale= 2
y = [1, 2]
y extend_list= [3, 4]
"""
print(effit.transpile_source(source))
# Output:
# x = 10
# x = scale(x, 2)
# y = [1, 2]
# y = extend_list(y, [3, 4])
How It Works
The Syntax Pattern
<target> <function_name>= <arguments>
| Component | Description |
|---|---|
<target> |
Any valid Python identifier, dotted name, or subscript |
<function_name> |
A valid Python identifier (not a keyword) |
= |
The assignment character (not ==) |
<arguments> |
Everything remaining on the line — passed as 2nd+ args |
Examples
| Before (effit syntax) | After (standard Python) |
|---|---|
x scale= 2 |
x = scale(x, 2) |
my_list append_items= [4, 5] |
my_list = append_items(my_list, [4, 5]) |
data merge= {"b": 2} |
data = merge(data, {"b": 2}) |
obj.attr transform= True |
obj.attr = transform(obj.attr, True) |
arr[0] scale= 3 |
arr[0] = scale(arr[0], 3) |
What is NOT matched (safety)
- Standard assignments:
x = 10 - Augmented assignments:
x += 1,x *= 2 - Comparisons:
if x == 2: - Patterns inside string literals:
"x scale= 2" - Patterns inside comments:
# x scale= 2 - Python keywords as the function name:
x return= 5
Architecture
effit/
├── __init__.py — Public API (activate, deactivate, run_string, transpile_*)
├── parser.py — Regex-based transpiler (transpile_line, transpile_source)
└── hook.py — PEP 302 import hook (EffitFinder, EffitLoader)
The transpiler works in three stages:
- Mask — String literals and comments are replaced with opaque placeholders.
- Match — A regex identifies the
target func= argspattern. - Rewrite — The matched line is rewritten as
target = func(target, args). - Unmask — Original strings and comments are restored.
Running Tests
pip install -e ".[dev]"
pytest
With coverage:
pytest --cov=effit --cov-report=term-missing
Metadata
Release files for effit 0.1.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 | Provenance | Actions |
|---|---|---|---|---|
| effit-0.1.0.tar.gz | 12.9 kB | Without provenance | Details for effit-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| effit-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for effit-0.1.0-py3-none-any.whl |
Total release size: 23.1 kB
Release files / effit-0.1.0.tar.gz
| Download URL | effit-0.1.0.tar.gz |
|---|---|
| Size | 12.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f7d25a043f6690ed18b965b1bc2f8fcc6f73a9182fb759cc2e05002b93f397b2
|
|
BLAKE2b-256 checksum How to use checksums |
57c76611a30878e69b8420e647ca446f0adf7c5c9729ac1cebc53403ee7ea24d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.0
|
Release files / effit-0.1.0-py3-none-any.whl
| Download URL | effit-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bfeda527c93b10d189ca54a45e96e4ab446a3213dc90f5248e18327462e05003
|
|
BLAKE2b-256 checksum How to use checksums |
7f407ab2e5436c0e2670f0eddb6ddc6a880232c5d8498c11df751b41a16a9171
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.0
|
Security for effit 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.