ideas: Making it easier to extend Python's syntax
The purpose of ideas is to allow you to easily implement changes in Python's syntax and be able to see their result either when importing files using your new syntax or in a specialized REPL, without having to change the Python interpreter itself.
Installation
python -m pip install ideas
Depending on your OS, you might need to write python3 or py instead of python in the above.
Usage
ideas -a my_cool_new_syntax [my_program[.py]]
Admitedly this is a bit terse ... Let's go into a bit more details.
Usage in more details
As a specific example of a new syntax, suppose that you want to use
function as a keyword in Python, to mean
the same thing as lambda, enabling you to write
# my_program.py
square = function x: x**2
print(f"{square(4)} is the square of 4.")
if __name__ == "__main__":
print("This is run as the main module.")
You can easily do this with ideas. The simplest way would be as follows:
# my_cool_new_syntax.py
from ideas import create_hook
def transform(source, **kwargs): # This will also replace lambda in strings :(
return source.replace("function", "lambda")
def add_hook():
create_hook(transform_source=transform, name=__main__)
Then to use it in an REPL, or optionally to run the python script mentioned above, all you would need to do is:
ideas -a my_cool_new_syntax [my_program]
That's it!
Much more can be found in the documentation.
Dependencies
- token-utils
- Python 3.8+ (it might even work with older versions, but is no longer tested.)
Tools
This project uses black for formatting, pytest for running tests, and flake8 for linting with custom settings compatible with black.
License
MIT
Metadata
Release files for ideas 0.3.14
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 |
|---|---|---|---|---|
| ideas-0.3.14.tar.gz | 13.8 MB | Without provenance | Details for ideas-0.3.14.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ideas-0.3.14-py3-none-any.whl | Python 3 | none | any | Details for ideas-0.3.14-py3-none-any.whl |
Total release size: 13.9 MB
Release files / ideas-0.3.14.tar.gz
| Download URL | ideas-0.3.14.tar.gz |
|---|---|
| Size | 13.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
08363b1bc20da555341f0bd9e18e09b345641f31237b3882f09ea79c55f448be
|
|
BLAKE2b-256 checksum How to use checksums |
f664af9bf1c496a5cfde9495535c75bd45cf9a7b2e59c099012c54902b82c185
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|
Release files / ideas-0.3.14-py3-none-any.whl
| Download URL | ideas-0.3.14-py3-none-any.whl |
|---|---|
| Size | 90.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
85ec022e06accbd7616ff6a6d6f5532fb07bc501fd1c1a427d1ee7cf544f22fa
|
|
BLAKE2b-256 checksum How to use checksums |
b0934ff004a52689902ad83ae5e3dccb64c4bbcc56782fa165f7b0b2fca0d725
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|
Security for ideas 0.3.14
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.