Implementing C-style for loops in Python for fun.
Project description
cursed-for
Implementing C-style for loops in Python.
This was implemented because of a cursed idea I had one night, which I put on twitter:
I wrote a blog on the approaches I went through to implement this.
The rough iterations that happened during the development are documented in the approach folder. It contains both the AST manipulation method, and the "truly cursed" method.
Installation
pip install cursed-for
The "old way" usage
Note that this only really works in a REPL. To start it, run cursedfor.py in the terminal. It's a single file, you can get it by just downloading the one file if you want to.
>>> from cursed_for import _for, var
>>> with _for(i := var(0), i < 10, i += 2):
... print(i)
0
2
4
6
8
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cursed_for-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cursed_for-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74e8bc6c363d3a02bc51c13de868a232d094a651a50fa1524659431d7f0602e0
|
|
| MD5 |
c48f2fbca3a5cf86a570300ec1e94935
|
|
| BLAKE2b-256 |
bdc5fdc3bd03fd250a543dbf25d07abbd13d34bff01b803be228d26c6660b59c
|