An automatic python code shortener
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pygolf-1.0.1.tar.gz
.
File metadata
- Download URL: pygolf-1.0.1.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using 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.45.0 CPython/3.6.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c60bcad7e1a24d526f95d0bb2e1c7a3ab3f0bb6edecef2eaced3c065eab07afe |
|
MD5 | e62875b0f8a306216d2a57dfe57d1de0 |
|
BLAKE2b-256 | 64a27e2a5190920ea1236f38691ea87a727b07905af0c3fdac490267b8f75d29 |
File details
Details for the file pygolf-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: pygolf-1.0.1-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using 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.45.0 CPython/3.6.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86a5bdce031fc71d629d2ed5f44d3834610e94cc62bb4f3547982d8d550ecf63 |
|
MD5 | 78c7191db9a7efd008c6c12112e9ff37 |
|
BLAKE2b-256 | a00b9402ccc40f0ae447c11400b60c2a7fd15004bd8111ccf1e8bcf85447249d |