PyGolf
PyGolf is a python code shortener.
PyGolf takes a valid python code as input and outputs an equivalent code with fewer characters.
You can find examples of reduced code in the folder code_example. These examples mainly come from CodinGame's Clash of Code game.
Getting Started
Installing
You can install this project directly from pypi with pip install pygolf
How to use it
You can call it using either pygolf or python -m pygolf.
You can:
- Give some code with
-c,pygolf -c "print( 2 )" - Give an input and output file,
pygolf -i input_file -o output_file - Shorten code in clipboard with
pygolf -cb(usefull while doing a clash of code)
To modify the clipboard, pygolf requires pyperclip. You might have some issues such as Could not find a copy/paste mechanism for your system. If so, refer to pyperclip guidelines.
How does it work
PyGolf uses astroid to parse and apply transformations on the abstract syntax tree (AST).
PyGolf parses and unparses the AST several times through phases. Each phase comes with rules.
If you want to contribute, please refer to the CONTRIBUTING.md file.
Release files for pygolf 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pygolf-1.0.2.tar.gz | 14.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pygolf-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.4 kB
Release files / pygolf-1.0.2.tar.gz
| Download URL | pygolf-1.0.2.tar.gz |
|---|---|
| Size | 14.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
60fff15944611d8d6818cabbb705e8481285a9b8e84fba4140ad053e0251ae24
|
|
BLAKE2b-256 checksum How to use checksums |
232f31a2a4fdbdbf5978328318f3f0dc9f60db9ce0c2af68ae3a4a772212c07d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.10
|
Release files / pygolf-1.0.2-py3-none-any.whl
| Download URL | pygolf-1.0.2-py3-none-any.whl |
|---|---|
| Size | 19.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7abf58912fd794454fac730954e1d1d22adb4c487572ac93f0d9db346c00526b
|
|
BLAKE2b-256 checksum How to use checksums |
756688dac6c3c5bd4c10ea971611a8bef6df2edf4d47e900af0e876e7d062351
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.10
|